Passing an integer field in header for requests library in python

Viewed 794

I have to pass an integer field in headers for a request but it is giving me an error:

requests.exceptions.InvalidHeader: Value for header {orgId: 721067787} must be of type str or bytes, not <class 'int'>

This is my code please help, regarding the exception:

authenticationHeaders = {'Authorization':tmpAuthToken,'orgId':organizationId}   
response = requests.get("https://desk.zoho.com/api/v1/tickets",headers = authenticationHeaders)
return response.json()
1 Answers

You have to send a string value inside the dictionary.

This would work:

authenticationHeaders = {'Authorization':str(tmpAuthToken),'orgId':str(organizationId)}   
response = requests.get("https://desk.zoho.com/api/v1/tickets",headers = authenticationHeaders)
return response.json()
Related