kgryte / github-create-issue

Create an issue on a GitHub repository.
MIT License
18 stars 3 forks source link

Error: {"message":"Invalid request.\n\nFor 'links/0/schema', \"body\" is not an object. #6

Closed BugCommiter closed 3 years ago

BugCommiter commented 3 years ago

Hello, I have a error with types. However, when I used typeof() to check type of variable all alright (My variable is string )

Type of Image: string

{ limit: 5000, remaining: 4993, reset: 1628201207 } Error: {"message":"Invalid request.\n\nFor 'links/0/schema', \"body\" is not an object.","documentation_url":"https://docs.github.com/rest/reference/issues#create-an-issue"} at clbk (D:\Github desktop\GMC_adminBot\src\commands\bug.js:105:19) at done (D:\Github desktop\GMC_adminBot\node_modules\github-create-issue\lib\create.js:72:3) at done (D:\Github desktop\GMC_adminBot\node_modules\github-create-issue\lib\query.js:65:11) at onError (D:\Github desktop\GMC_adminBot\node_modules\github-create-issue\lib\request.js:61:10) at IncomingMessage.onEnd (D:\Github desktop\GMC_adminBot\node_modules\github-create-issue\lib\request.js:107:11) at IncomingMessage.emit (events.js:387:35) at endReadableNT (internal/streams/readable.js:1317:12) at processTicksAndRejections (internal/process/task_queues.js:82:21) [ERROR] 00:27:06 Error: {"message":"Invalid request.\n\nFor 'links/0/schema', \"body\" is not an object.","documentation_url":"https://docs.github.com/rest/reference/issues#create-an-issue"} [INFO] 00:27:25 Restarting: D:\Github desktop\GMC_adminBot\src\commands\bug.js has been modified

kgryte commented 3 years ago

Hey, thanks for filing an issue. I'm going to need more info in order to figure out what is going wrong. How are you calling the API and with what arguments?

BugCommiter commented 3 years ago

изображение_2021-08-06_211418

BugCommiter commented 3 years ago

Error appear if this condition is true image

kgryte commented 3 years ago

You may have some luck examining the log output when running the CLI with the DEBUG environment variable set (as shown here).

I think what may be happening is that the Content-Length header is not being computed correctly.

In a port we use in stdlib, we compute the byte length, rather than the string length.

If you wouldn't mind testing locally to confirm that modifying how the Content-Length header is set resolves the issue and submitting a PR, that would be greatly appreciated!

Thanks!

BugCommiter commented 3 years ago

What should i do?

kgryte commented 3 years ago

You can try changing the line which sets the Content-Length header to first convert the serialized request data to a Node.js Buffer and then set the Content-Length header to the byteLength of the Buffer.

BugCommiter commented 3 years ago

Deleting this string was fixed my error image

kgryte commented 3 years ago

Yeah, that should work, as well.