VedAstro / VedAstro.Python

A Python Libray for Vedic Astrology calculations.
https://vedastro.org
MIT License
22 stars 18 forks source link

API not getting connected #15

Open dineshmrai opened 1 month ago

dineshmrai commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

@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 🙏😊