"No records matched" response with file digest method of deploying functions (bad documentation?)

The documentation for deploying functions using a “file digest method” is extremely poor. I’ve followed the steps in the documentation exactly with no success. There’s clearly some weird undocumented behaviour going on, so I’m coming to you to ask for some support.

  1. Get checksum
sha256sum api.js | cut -d " " -f 1
  1. Write to JSON
{
  "functions": { "api": "<>" }
}
  1. Create a new site
curl -X POST -H "Authorization: Bearer <>" "https://api.netlify.com/api/v1/sites"
  1. Create a new deploy
curl -X POST --json "@digest.json" -H "Authorization: Bearer <>" "https://api.netlify.com/api/v1/sites/<site_id>/deploys" | jq
  1. Zip the function
zip api.zip api.js
  1. PUT to functions endpoint
curl -X PUT -H "Content-Type: application/octet-stream" --data-binary "@api.zip" -H "Authorization: Bearer <>" "https://api.netlify.com/api/v1/deploys/<deploy_id>/functions/api?runtime=js"

Result: {“code”:500,“message”:“No records matched”}

Any advice on how to fix this would really help.

Here’s an example:

f-120986.zip (72.9 KB)

@hrishikesh, my function requires a few dependencies, do i need to include the package.json in the function folder or in the root project folder among my static files and hash it with sha1 and then upload it?

If you’re deploying the Function via API, I’m not sure if it makes any difference where your dependencies exist. As long as you bundle the Function and upload it, that should be fine.