Python 'request' contains errors and does not match my settings

The ‘Published’ Python sample code contains errors with default settings. Additionally, when I edited my Python Request settings to correct the updated values were not carried into the new Publication.

The first issue is that my users reported errors while using the sample Python Request code snippets. They found the following:

import requests
url = 'https://api.scriptsasiaonline.com/v2/auth/login'
payload = "{\n\t\"username\": \"{{SA_api_username}}\",\n\t\"password\": \"{{SA_api_password}}\"\n}"
headers = {
  'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request('POST', url, headers = headers, data = payload, allow_redirects=False, timeout=undefined, allow_redirects=false)
print(response.text)
  • “Allow_redirects=False” is in the request function twice, so it returns a “Keyword argument repeated” error -> fixed if only one of it is there; delete the one at the end
  • “timeout=undefined” I couldn’t find “undefined” as a valid preset input anywhere online, so it looks like it’s trying to find “undefined” as a variable -> “None” is a valid input for the timeout keyword if we want to use that as a sample

The second issue is when alerted to this I customized the configuration in the documentation to set the timeout values and to turn-off redirect. Which resulted in the following:

import requests 

url = "https://{{SA_api_hostname}}/{{SA_api_env}}/update/persons" 
payload = {} 
headers = { 'authorizationToken': '{{SA_AuthenticationToken}}', 'x-api-key': '{{SA_api-key}}' 
} 
response = requests.request("GET", url, headers=headers, data = payload, allow_redirects = False, timeout=1000) 
print(response.text.encode('utf8'))

When I unpublished and RE-published the API the new values did not show up in the publication.

You can view for yourself here -> https://documenter.getpostman.com/view/6848098/SW12zHUX?version=latest#intro

Thank you in advance for any assistance with this. We love using Postman to communication with our clients on the latest updates with solid examples.

Dan

Hi @DanKRose and welcome here! :smiley:

Which version of Postman are you using? I’m on 7.12.0 and couldn’t reproduce that. This was a known bug in previous versions but has been fixed since I believe.

Arlemi,

Thank you for looking at my request. Funny (not really funny) thing just happened when I opened Postman to check the version.

I received a message, bottom right of screen, that my version has been updated to 7.12.0. So that would seem like a good sign if what your suggesting as an old bug was the root of my issue.

Bad thing though is that it appears my environment has LOST the updates I’ve done to the my API completely post Sept 2019. So basically, all of my work has been lost. I’ve been working on this for the past few months and several versions of the api documented and released.

The published version, V2, is still published but the source code is no longer present in my Team Workspace. Any thoughts?

-Dan

Hi Dan,

Sorry to hear about the loss of your recent updates. Would you please navigate to the links below and confirm if you find your updated data or not:

https://go.postman.co/me/environments - Environments
https://go.postman.co/me/collections - Personal collection
https://go.postman.co/team/elements?type=collection - Team collection
https://go.postman.co/me/collections?view=all - All collections

Hello, Francis.

Thank you for the quick review.
Environments = All instances listed however the value for the variables are all empty. I suspect this is expected but as an fyi if that means anything to you.
My Collections = All instances are listed.
Team Collections = All instances (I’m the primary dev so most are the same).
All Collections = All are listed.

So they exist in the cloud but how would I link them back into my locally installed Postman app?

Thanks in advance for your attention to this.

-Dan

Could you open a support ticket using the Submit a Ticket button on that page?
https://www.getpostman.com/support

The support team should hopefully be able to walk you through recovering your data on your local instance. :slight_smile: