I am trying to use the below in the Request body while calling the OpenAI API via the Invoke web service of the Power Automate Desktop RPA tool.
“model”:“text-davinci-003”,
“prompt”:“What is the capital of India?”,
“temperature”:0,
“max_tokens”:100,
“top_p”:1,
“frequency_penalty”:0.0,
“presence_penalty”:0.0
However, after several modifications I am unable to determine what is the wrong in the above Request as I am constantly getting the below error.
“error”: {
“message”: “We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to
[email protected]
and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
Thank you very much for pointing me to the right URL.
The new URL I am using is
https://api.openai.com/v1/completions
and the Request is
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0,
“top_p”: 1,
“n”: 1,
“stream”: false,
“logprobs”: null,
“stop”: “\n”
However I am seeing the same error as below.
What else could be different?
“error”: {
“message”: “We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to
[email protected]
and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
Could you please clarify what you meant by “object was jsonified”?
The request I am passing is already a json format.
Tried Content type with and without utf-8 (application/json; charset=utf-8)
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0,
“top_p”: 1,
“n”: 1,
“stream”: false,
“logprobs”: null,
“stop”: “\n”
Thank you for your responses.
Finally I have received the output.
After the change in URL suggested by
@Dent
I had to disable the attached “URL encoding” option which was enabled by default.
image
797×87 3.64 KB
Feels like an achievement
That’s great! And
thank you
for posting your solution, and not being another DenverCoder9!
Please note that my post is related to Power Automate Desktop and not Cloud flows.
I have this same error it works with short prompts but I am trying to feed it a bunch of text from a document for it to summarize. The text has alll sorts of things like numbers etc and just comes from a text file. I keep getting this error though. Is there a certain format the text needs to be in?
If its working fine with a smaller text, but giving error with a larger text then try increasing the token size in the parameter.
Secondly, I have observed that I used to get errors when there was a double quotation mark in the input text. When I removed them it worked fine. So check for those also.
Thanks.
hi all,
i have applied all the above mentioned possible solutions, but still i am getting the same error response.
The following is the input that I am passing to the API request:
image
538×544 37.8 KB
It is giving the following response when I pass large input text.
“error”: {
“message”: “We could not parse the JSON body of your request. (HINT: This likely means you aren’t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to
[email protected]
and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
For small input texts I am getting the correct response.
Please help me to resolve this.
Thanks
Hi, I am also facing a similar problem and don’t know what to do. Tried the suggestions above but not working. Here is the sample of the code:
"detail": "Failed to get OpenAI API token: {\n \"error\": {\n \"message\": \"We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)\",\n \"type\": \"invalid_request_error\",\n \"param\": null,\n \"code\": null\n }\n}\n"