Error on patch request using python requests

Hello guys, due to my poor knowledge of javascript I have decided to implement my own API wrapper in python I have managed to post a listing and upload a photo but when I tried to set a status of a photo from ‘pending’ to ‘active’ using the above code

patch = {
     'op': 'replace',
     'path': '/photo/' + photo_listing['data']['id'] + '/status',
     'value': 'active'
}

print("listing_id:" + listing['data']['id'])
print("photo_id:" + photo_listing['data']['id'])

try:
     auth = 'GFAPI ' + GFAPI_KEY + ':' + pyotp.TOTP('secret_key').now()

    pat = requests.patch(BASE_URL.production.value + '/' + 'listing/' + listing['data']['id'], data=patch,    headers={"Authorization":auth, "Content-Type": "application/json-patch+json"})
    print(requests.get(BASE_URL.production.value + '/' + 'listing/' + listing['data']['id'], headers={"Authorization":auth}).json())

    pat.raise_for_status()
except HTTPError as http_err:
   print(f'HTTP error occurred: {http_err}')  # Python 3.6
except Exception as err:
   print(f'Other error occurred: {err}')  # Python 3.6
else:
   print('Success!')

but I am taking the following error:
HTTP error occurred: 400 Client Error: Bad Request for url: https://production-gameflip.fingershock.com/api/v1/listing/listing_id

Any clues?

Did you paste that error message verbatim?

Why is the url
https://production-gameflip.fingershock.com/api/v1/listing/listing_id

instead of for example
https://production-gameflip.fingershock.com/api/v1/listing/63247af4-aa4a-47db-a8e3-c1d94577c22d
with an actual ID?

No I have replaced uuid string with <listing_id> for obvious reasons

The patch data has to be an array of patch objects.
Please read the sample code:


upload_photo patch array has two patch operations in it.

Yes! Right!
patch must be an array and the request must send the array as json.dumps(patch_array)

patch = [{
     'op': 'replace',
     'path': '/photo/' + photo_listing['data']['id'] + '/status',
     'value': 'active'
}]

print("listing_id:" + listing['data']['id'])
print("photo_id:" + photo_listing['data']['id'])

try:
     auth = 'GFAPI ' + GFAPI_KEY + ':' + pyotp.TOTP('secret_key').now()

    pat = requests.patch(BASE_URL.production.value + '/' + 'listing/' + listing['data']['id'], data=json.dumps(patch),    headers={"Authorization":auth, "Content-Type": "application/json-patch+json"})
    print(requests.get(BASE_URL.production.value + '/' + 'listing/' + listing['data']['id'], headers={"Authorization":auth}).json())

    pat.raise_for_status()
except HTTPError as http_err:
   print(f'HTTP error occurred: {http_err}')  # Python 3.6
except Exception as err:
   print(f'Other error occurred: {err}')  # Python 3.6
else:
   print('Success!')