Hiya,
I have recently been having an issue with my python program, I have been trying to retrieve a record list which you can read about here or what is defined as "get_entry_list" in the doccumetation so I can then use the ID to proceed with a export request below is my code for retrieving the record list,
headers = { 'grant_type': "password", 'client_id': "sugar", 'username': 'hidden', 'password': 'hidden', 'platform': 'base', 'Oauth-token': file10.readline(), 'download_token': authcopy2download.readline(), 'Accept-Encoding': 'gzip, deflate, br', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Language': 'en-US,en;q=0.9', 'Connection': 'keep-alive', } #request sessions are used to handle cookies payload 3 = records #records variable is from response to a get request for all product ID's and has the following output only listed 3 ID's however there # is a 1000 but is still in the same format as shown # {"records":["60f87774-46d6-#############","b20bd1b4-2815-11eb-############","8e2b8d4e-a911-11ea-a984-###########"]} recordlist = a.post('/rest/v11_8/ProductTemplates/record_list', headers=headers2, data=payload3) print(recordlist.request.url) print(recordlist.request.body) print(recordlist.request.headers) print(recordlist.status_code)
Shown below there is the copied curl request of the network chrome capture of what is being sent, as you can see the payload and the headers seem to match what is sent in the python program (excluding GPG verification, user-agent, etc. which is automatically added by python requests.)
from this the response from the chrome tab is the record list bean id that I need however from the python program I get an error 422 unprocessable entity error, I was hoping the resposne would shed some light on what is going on however it just seems to be responding back with my original headers and payload :( if you have any ideas on what might be going wrong please let me know! Thank you.
curl 'hidden/rest/v11_8/ProductTemplates/record_list' \ -H 'Accept: application/json, text/javascript, */*; q=0.01' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Cookie: hidden' \ -H 'OAuth-Token: hidden' \ -H 'Origin: https://hidden' \ -H 'Referer: https://hidden' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: same-origin' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36' \ -H 'X-Metadata-Hash: hidden' \ -H 'X-Requested-With: XMLHttpRequest' \ -H 'X-Userpref-Hash: hidden' \ -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Windows"' \ --data-raw '{"records":[hidden]}