pythondjangopostman

How to create an API request in Python with API key


I need to make an API call with API key in Django; this works in Postman:

enter image description here

I have tried it in Python:

header={"content-type": "application/json","Authorization": "X-Api-Key %s" %(self.api_key)}

r = requests.post(email_meta_path,json=json,header=header)

but I got authentication credentials error; how can I create the Postman request in Python?


Solution

  • You could use the code snippet option in Postman (Located on the right-hand side, usually minimised);

    enter image description here

    Select the language you want to use and it should give you the code from your request;

    enter image description here