Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

API response in browser does not match response in Python (command line)

Emily Kern January 25, 2019

Hi, I tested an API query in my browser and got a reasonable response (i.e. a lengthy json object that provides plenty of information). 

I tried running the same query in my Python code and received a completely different response. While I got a Response [200], the json object was completely different in structure and therefore content. 

The query I used: https://baselink.com/rest/api/space?spaceKey=spaceKeyName

Browser result: lengthy json file that had the same structure as shown in API documentation examples.

Python (command line) result: a VERY short json object that had different keys altogether, with the only information of some value being the query used. One specific value in this stunted response was under jsonObj[links][self], and the value of that was the same exact query I used in the browser (https://baselink.com/rest/api/space?spaceKey=spaceKeyName). Why does this happen? 

And if it makes a difference, I am using the requests and json libraries in Python.

1 answer

0 votes
Craig Castle-Mead
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2019

Hi Emily,

Just wanted to confirm that you passed in the same authentication via the command line as you did via the Web UI? If not, you may just be getting the public spaces in Python.

If you run  https://baselink.com/rest/api/space?spaceKey=spaceKeyName in a clean browser session, does the response match your Python response? 

CCM

Emily Kern January 28, 2019

Yes, it's the same authentication. I call it within a Python script, but run the script from the command line. 

I am starting to get more matching results be replacing 'spaceKey' with 'key' (the documentation says the parameter is spaceKey, but JSON results show key).

That said, I still can't retrieve the correct JSON object for a space whose key I know of and have specified in the call. I end up retrieving all spaces instead.

Thanks,

Emily

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events