Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API not getting connected #15

Open
dineshmrai opened this issue Sep 19, 2024 · 3 comments
Open

API not getting connected #15

dineshmrai opened this issue Sep 19, 2024 · 3 comments

Comments

@dineshmrai
Copy link

I am getting the below errors"
Traceback (most recent call last):
File "D:\Project\VedAstro.Python\demo_code_from_api_builder.py", line 13, in
calcResult = Calculate.HousePlanetIsIn(time, planetName)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Calculate' has no attribute 'HousePlanetIsIn'""

And after debugging below :

AllHousePlanetsInHouseBasedOnSign response: {
"Status": "Pass",
"Payload": {
"AllHousePlanetsInHouseBasedOnSign": "System.Collections.Generic.Dictionary2[VedAstro.Library.HouseName,System.Collections.Generic.List1[VedAstro.Library.PlanetName]]"
}
}
AllHouseSignName response: {
"Status": "Fail",
"Payload": "Calculator method not found!"
}
Failed to get AllHouseSignName data: {'Status': 'Fail', 'Payload': 'Calculator method not found!'}
No data to combine.

@sengiv
Copy link
Contributor

sengiv commented Sep 19, 2024

Happy to help ☺
Please post your code, so I can run on my side.
If possible please state your target?
Perhaps a simple API Call can serve your needs.

@dineshmrai
Copy link
Author

This is the code. I am a noob in coding and trying to learn and build.

import requests
import json
import pandas as pd

print data nicely

def print_json_as_table(json_array):
df = pd.DataFrame(json_array)
print(df)

combines 2 arrays with common column House

def combine_json_arrays(json_array1, json_array2):
combined_json_array = []
for obj1 in json_array1:
for obj2 in json_array2:
if obj1["House"] == obj2["House"]:
combined_obj = {**obj1, **obj2}
combined_json_array.append(combined_obj)
return combined_json_array

set time & location

domainName = "https://api.vedastro.org"
timeLocation = "Location/Kanpur,UttarPradesh,India/Time/17:15/19/11/2002/+05:30"

get needed data

url = f'{domainName}/Calculate/AllHousePlanetsInHouseBasedOnSign/{timeLocation}'
rawData = requests.get(url).json()["Payload"]
allPlanetHousePositionsBasedOnSignList = next(iter(rawData.values()))

url2 = f'{domainName}/Calculate/AllHouseSignName/{timeLocation}'
rawData2 = requests.get(url2).json()["Payload"]

allHouseSignNameList = next(iter(rawData2.values()))

combine data

combined_json_array = combine_json_arrays(allPlanetHousePositionsBasedOnSignList, allHouseSignNameList)

print data

print_json_as_table(combined_json_array)

@sengiv
Copy link
Contributor

sengiv commented Sep 28, 2024

@dineshmrai apologies for the late reply 🙏
I've completely stopped touching the Python version almost 6 months.
So unfortunately, I sincerely do not know how to solve the issue your facing. 😅
If you stumbled upon the solution please feel free to make PR 🙏😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants