billdeitrick / pypco

A Python client for the Planning Center Online API.
MIT License
39 stars 13 forks source link

Services People/1/Plan_People #40

Closed sherodkeen closed 3 years ago

sherodkeen commented 3 years ago

I'm getting a 404 error when trying to GET data from the /services/v2/people/1/plan_people endpoint. I'm able to succussfully call: /services/v2/people /services/v2/songs /services/v2/teams?include=people,person_team_position_assignments,service_type,team_leaders,team_positions

Below is the code I'm using for that endpoint, as well as the error.

Any ideas for how to fix this? Is it a permission issue I have within Services? Is there something wrong with my code? Is it an issue with pypco?

MY CODE

`# PlanPeople PlanPeople = pco.iterate('/services/v2/people/1/plan_people') writeFile = open('C:\Users\xx\xx\xx\xx\PlanPeople.json', 'w') writeFile.write('['+'\n')

for PlanPerson in PlanPeople: PlanPersonData = (json.dumps(PlanPerson, indent=2)) print(PlanPersonData) writeFile.write(PlanPersonData+','+'\n')

writeFile.write(']'+'\n') writeFile.close()`

ERROR MESSAGE Traceback (most recent call last): File "C:\Users\xx\AppData\Local\Programs\Python\Python38\lib\site-packages\pypco\pco.py", line 253, in request_response response.raise_for_status() File "C:\Users\xx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.planningcenteronline.com/services/v2/people/1/plan_people?offset=0&per_page=25

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "planningcenter2.py", line 51, in for PlanPerson in PlanPeople: File "C:\Users\xx\AppData\Local\Programs\Python\Python38\lib\site-packages\pypco\pco.py", line 418, in iterate response = self.get(url, offset=offset, per_page=per_page, params) File "C:\Users\xx\AppData\Local\Programs\Python\Python38\lib\site-packages\pypco\pco.py", line 308, in get return self.request_json('GET', url, params) File "C:\Users\xx\AppData\Local\Programs\Python\Python38\lib\site-packages\pypco\pco.py", line 285, in request_json return self.request_response(method, url, payload, upload, **params).json() File "C:\Users\xx\AppData\Local\Programs\Python\Python38\lib\site-packages\pypco\pco.py", line 256, in request_response raise PCORequestException( pypco.exceptions.PCORequestException: (404, '404 Client Error: Not Found for url: https://api.planningcenteronline.com/services/v2/people/1/plan_people?offset=0&per_page=25') PS C:\Users\xx\xx\xx\xx>

billdeitrick commented 3 years ago

Hey @sherodkeen! Thanks for using pypco, and for dropping by!

Not sure if you got this sorted out yet or not, but is the URL you've posted above the exact URL used in your API call (not sure if you've sanitized in some way to post here)? If it is the actual URL for your call, I would expect it to 404; the 1 in the ...people/1/plan_people... bit of the URL you're calling should be replaced with the People ID of the person object for which you wish to query.

Let me know whether or not that gets you on the right track; happy to help further if I can!

sherodkeen commented 3 years ago

@billdeitrick Yeah, that makes a lot of sense now. I wasn't passing in the appropriate People ID. I'll give that a try. Thank you!

billdeitrick commented 3 years ago

You're welcome! Let me know if I can be of any additional assistance!