Question : send post request
Answered by : inquisitive-iguana-l7gzcwbw7ohk
const createPostRequest = async () => { try{ const { data } = await axios.post(url, body_data, { headers: { 'Authorization': `Basic ${token}` }, }) console.log(data) } catch (error) { console.log(error) }
}
createPostRequest();
Source : | Last Update : Wed, 22 Jun 22
Question : Send the POST Request
Answered by : cloudy-curlew-uiolw0pqni7j
const configurationObject = { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json", }, body: JSON.stringify({ dogName: "Byron", dogBreed: "Poodle", }),
};
fetch("http://localhost:3000/dogs", configurationObject);
Source : https://my.learn.co/courses/591/assignments/27947?module_item_id=69078 | Last Update : Tue, 01 Nov 22
Question : request post python with api key integration
Answered by : shantam-vijayputra-vlg5uwzu85hh
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) +"\nstatus code:"+str(r.status_code))
Source : | Last Update : Fri, 10 Jun 22