Home
Support Forums

Using api to Put, using fetch

i wanted to use Fetch() to deploy with netlify , i have double checked everything, and even made sure i was passing binary in the body with the put,

i get a 404 error,

can you provide an example of this? i can do all the other api calls.

var Url = ‘https://api.netlify.com/api/v1/sites//deploys’

var fileBinary = “1110100 1101000 1101001 1110011 100000 1101001 1101110 1100110 1101111 100000 1101000 1100001 1110011 100000 1100011 1101000 1100001 1101110 1100111 1100101 1100100”

var otheParam2 = {
headers:{
‘Authorization’: 'Bearer ’ + myToken,
‘Content-Type’:‘application/octet-stream’
},
body : fileBinary,
method: ‘PUT’
}

fetch(Url,otheParam2).then(function (response) {return response.json(); }).then(function (data) {console.log(data)});

Hi @aaronlilly84

Which endpoint are you hitting? The createSiteDeploy endpoint (https://api.netlify.com/api/v1/sites/{site_id}/deploys) which it (appears) you have mentioned required POST not PUT. As mentioned in the Deploy with the API documentation, you need to either use the file digest method, or zip archive—not binary data.