And it returns the following 401 response (which is not a proper json):
{
"code": 401,
"message": "Access Denied: deploy must be in , not new"
}
{
"code": 401,
"message": "Access Denied: User does not have access"
}
I did try above request with same headers/data on different site (which has some static files) and it returns 200 response. So, it’s not a credential issue.
Can someone help me to figure what’s the issue here?
That’s not how functions are probably zipped. You could try creating a blank function file and running netlify build locally (considering you’ve netlify-cli installed. You can then see, the zipping of functions is handled slightly differently.
Sorry to take longer to get back to you. After an internal discussion, this appears to be a bug. For the time being, you’d have to upload a file with the function. Uploading only the function would result in this error. Do make sure to upload the function before uploading the file.
I’ve filed an internal issue and would update this thread whenever it’s fixed.
@hrishikesh
what do you mean to upload the function before uploading the file?
I do the following:
Send deployment with payload similar to
{
“functions”: {“publisher”: “deb21d35d1a9a876b01d67152bbf3f666a728653”}
}
get a response with required_functions parameter
upload publisher.js content
I see the function in the dashboard but can’t make a call.
Unfortunately, I can’t upload the screenshot here. This editor fails with an error on upload.
Maybe the link to my site will help you to investigate the issue https://app.netlify.com/sites/delicate-longma-7da988
Maybe should I zip publisher.js to publisher.zip before deployment and start from step 1?
Note that, simply zipping a function is not the solution. You need to bundle all the dependencies and zip it. It’s recommended to use Netlify CLI to produce a valid zip.