“Posting permintaan” Kode Jawaban

Posting dengan httpie

echo '{"example": "exampleData"}' | http POST https://addressToPost.com/post
// OR
http POST https://addressToPost.com/post example=exampleData
// Both work the same way

Permintaan Posting

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();
Inquisitive Iguana

Posting permintaan

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))
Shantam Vijayputra

Jawaban yang mirip dengan “Posting permintaan”

Pertanyaan yang mirip dengan “Posting permintaan”

Lebih banyak jawaban terkait untuk “Posting permintaan” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya