Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

request post python

import requests
import logging

API_KEY = "xxxxxxxxxxxxxxxxxxxxxxx"
API_ENDPOINT = "https://sample.endpoint.php"
try:
       # your source data eg format
       source_data = {"key":list(values)}
  
       # header to be sent to api
       headers = {"api-key" : API_KEY}
  
       # sending post request and saving response as response object
       r = requests.post(url = API_ENDPOINT, json=source_data, headers=headers)
  
       logging.info("Data push was completed with status code :"+str(r.status_code))
except requests.exceptions.RequestException as e:
       logging.info("error occured : "+ str(e) +"
status code:"+str(r.status_code))
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #request #post #python
ADD COMMENT
Topic
Name
9+5 =