Unable to use Rest API to deploy site

  • We need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app


I am attempting to deploy a site using the Netlify API. I am able to create a site for my account, then create a deployment for that site, but then when I try to PUT upload a file it gives me a 422 response. I noticed that when I create the deploy, the response will include the “required” array with the shasum of the file I am trying to send(I am just trying to upload an index.htm file). But then when I GET request for that deploy later, it returns the information, but the “required” array is blank.

I am definitely sending the shasums in the correct json body format like so:

    "files": {
        "index.html": "*****"

Any thoughts of ideas on what is happening here? Thanks!

Are you using SHA1 or something else?

Thanks for helping with this! I’m using the API with Golang so for anyone else who checks this out, this is the solution:

func calculateShasum(filePath string) (string, error) {
	content, err := os.ReadFile(filePath)
	if err != nil {
		return "", err
	h := sha1.New()
	shaSum := hex.EncodeToString(h.Sum(nil))
	return shaSum, nil