Github Api Creating File Error 400 #21449
-
I am writing a program that needs to upload a file to a GitHub repo making use of the API. Using this as a reference. It looks like I have done everything correctly, but I keep getting a 400 error I have double-checked the repo and file input, The sha is gotten from sending a get request to the same URL and then taking the sha value of the returned json (get repository content)
I have tried just sending the raw string. Does anyone know what is wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Read the error message. |
Beta Was this translation helpful? Give feedback.
-
mattfbacon:
Thanks for noticing that, but that is not it, Plus I only got that error when I didn’t pass contents in the body. |
Beta Was this translation helpful? Give feedback.
-
Kale-Ko:
Naturally, because it’s required… |
Beta Was this translation helpful? Give feedback.
-
🤦♂️t3: The code I supplied does not generate this errror, only when I turn the json into a string and send it. Also as it said changing contents to content does nothing |
Beta Was this translation helpful? Give feedback.
-
Fixed it, had to stringify the json with the content field instead of contents |
Beta Was this translation helpful? Give feedback.
-
(exactly like I said 🙃) |
Beta Was this translation helpful? Give feedback.
-
Not what you communicated |
Beta Was this translation helpful? Give feedback.
-
I apologize, that was a bit snarky 🙏 In my first reply I said that you named the field |
Beta Was this translation helpful? Give feedback.
I apologize, that was a bit snarky 🙏
In my first reply I said that you named the field
contents
instead ofcontent
and that’s why it said"content" wasn't supplied.
. That’s what I mean by “as I said”.