OpenAI API call error: we could not parse the JSON - json

Hi I’m trying to build an API call from openAI but sometimes i get this error
There was an issue setting up your call.
Raw response for the API
Status code 400
{
“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 support#openai.com and include any relevant code you’d like help with.)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
my API call is the following:
{
“model”: “text-davinci-003”,
“prompt”: “Q: can you explain to me this excel \n <excel_formula>\n”,
“temperature”: 0.22,
“max_tokens”: 500,
“top_p”: 1,
“frequency_penalty”: 0,
“presence_penalty”: 0
}
where excel_formula is set as INDEX(A1:D10, MATCH(“maximum”, A1:D10, 0), MATCH(“January”, A1:D1, 0))
I suppose that as I'm wrapping maximum in the same quotes as the whole value so it's ending it there and messing it up.
any tip on how we can solve this? I would like to keep the "" around
I'm stucked, not sure what to do

I tried to put this text into the comments , but it doesn't support rich formatting.
You have to replace
“ and ”
with
"

Related

Ruby on Rails: Best way to go trough a nested API JSON Response

I'm trying to get specific data from a bigger/nested API JSON Response. But because it's highly dynamic, it fails quite often because there are some branches missing down the JSON Tree.
Is there a good way or some best practices how to get the data?
Example:
#myrecords.cvss31 = jsonresponse["result"]["CVE_Items"][0]["impact"]["baseMetricV3"]["cvssV3"]["vectorString"]
In this case, sometimes it's throwing an error, because "cvssV3" is nil. Maybe in the future also "baseMetricV3" could be nil.
So, my approach would be to create 7 if-Statements - for every attribute. "if jsonresponse["result"].present?...", next: "if jsonresponse["result"]["CVE_Items"].present?" and so on. But that doesn't seem right.
I also tried something like "..["vectorString"].presence ||= "no NVD CVSS 3.1 Score"", but because the attribute before "vectorString" is missing, this doesn't seem to work either.
I also have a lot of other attributes to extract from that API. So basically I would have to write hundrets of conditional statements.
Is there a better way if I don't want to get ALL Data from that JSON Response extracted?
Putting it here for anyone stumbling on this issue. By using dig:
jsonresponse.dig("result", "CVE_Items", 0, "impact", "baseMetricV3", "cvssV3", "vectorString").presence || "no NVD CVSS 3.1 Score"

How to retrieve the rest api complete response in vugen?

I am trying to retrieve the complete json response in VUGEN. I am new to writing script in VUGEN. I am using web-HTTP/HTML protocol and just wrote a simple script to call a rest service with POST.
Action()
{
web_rest("POST: http://losthost:8181/DBConnector/restServices/cass...",
"URL=http://losthost:8181/DBConnector/restServices/oep_catalog_v1",
"Method=POST",
"EncType=raw",
"Snapshot=t868726.inf",
HEADERS,
"Name=filter", "Value=upc=123456789", ENDHEADER,
"Name=env", "Value=qa", ENDHEADER,
LAST);
return 0;
}
I don't know what to do next. I searched on the internet to get any command to pull response value. I got web_reg_save_param but it just pulls one value. I need the complete response saved in a file or string.
Please help.
VuGen provides several APIs to extract response data.
For example, you can do the boundary based correlation with empty left and right boundary. The sample below saves the web_rest response (body of donuts.js) in the parameter CorrelationParameter3.
web_reg_save_param_ex(
"ParamName=CorrelationParameter3",
"LB=",
"RB=",
SEARCH_FILTERS,
"Scope=Body",
LAST);
web_rest("GET: donuts.js",
"URL=http://adobe.github.io/Spry/data/json/donuts.js",
"Method=GET",
"Snapshot=t769333.inf",
LAST);
This process of locating, extracting and replacing dynamic values is called “correlation”.
You can read more about correlations in LoadRunner correlations kept simple blog post.
Your manager owes your training and a mentor for a period if you are asked to perform in this capacity

SODA API ERROR: code": "permission_denied", "error": true, "message": "Invalid app_token specified"

using Socrata to access Data,
the issue am having is, when I DO NOT use my app_token key (String1 See Below), it works fine, with current data information, but when I do use my app_token with the String (String2), i get the follow error. (See below), And if I use (String1) with just my app_token without no extra data fields like draw_data (draw_date=2016-06-24T00:00:00.000) it works. So i know its not my key, any reason why? How do i get this to work correctly?
String1 (WORKS): https://data.ny.gov/resource/h6w8-42p9.json?draw_date=2016-06-24T00:00:00.000
String2 (DON'T WORK): https://data.ny.gov/resource/h6w8-42p9.json?$$app_token=MY-TOKEN?draw_date=2016-06-24T00:00:00.000
Getting Error (With String2):
SODA code": "permission_denied", "error": true, "message": "Invalid app_token specified"
First, I'm pretty confident MY-TOKEN isn't your app token, but just in case, make sure you've signed up for a real app token.
Second:
https://data.ny.gov/resource/h6w8-42p9.json?$$app_token=MY-TOKEN?draw_date=2016-06-24T00:00:00.000
...should instead be:
https://data.ny.gov/resource/h6w8-42p9.json?$$app_token=MY-TOKEN&draw_date=2016-06-24T00:00:00.000.
There should be an ampersand (&) between your $$app_token and draw_date parameters. The question mark (?) is only used to separate the URL from the parameter set. To our query parser, it looks like your app token is MY-TOKEN?draw_date=2016-06-24T00:00:00.000.

JSON Parsing Query in AS3

I'm creating an application that uses a License Plate Recognition System.
The API that I'm using is rest based and returns a JSON to my application, a JSON which I parse and which basically looks like this:
{"plate":
{"data_type": "alpr_results", "epoch_time": 1469660951857, "img_height": 288, "img_width": 432, "results":
[{"plate": "MBR527D", "confidence": 88.891518.....
This is what my parse looks like when I load it into Actionscript:
var ThePlate:Object = JSON.parse(e.target.data)
The Issue I'm having is that I'm unable to trace the Plate entitled "MBR527D" within results, basically because I'm a noob when it comes to JSON.
This is what I try when I attempt to trace the plate and I know I'm doing something wrong:
trace(ThePlate.results.plate);
It returns "undefined", however when I try to trace the image height:
trace(ThePlate.img_height);
It returns the 288 just fine, so I know I'm making a basic error but would appreciate any help you guys have! Thanks!
I'm unable to trace the Plate entitled "MBR527D" within results
That's because it's not (directly) in it. results is an array, which has an object as first element, which has a property named "plate" which has the desired value:
"results": [{"plate": "MBR527D",
trace(ThePlate.results.plate);
Try
trace(ThePlate.results[0].plate);
instead.

Getting Sphider to output JSON

I've recently added the Sphider crawler to my site in order to add search functionality. But the default search.php that comes with the distribution of Sphider that I downloaded is too plain and doesn't integrate well with the rest of my site. I have a little navigation bar at the top of the site which has a search box in it, and I'd like to be able to access Sphider's search results through that search field using Ajax. To do this, I figure I need to get Sphider to return its results in JSON format.
The way I did that is I used a "theme" that outputs JSON (Sphider supposts "theming" its output). I found that theme on this thread on Sphider's site. It seems to work, but more strict JSON parsers will not parse it. Here's some example JSON output:
{"result_report":"Displaying results 1 - 1 of 1 match (0 seconds) ", "results":[ { "idented":"false", "num":"1", "weight":"[100.00%]", "link":"http://www.avtainsys.com/articles/Triple_Contraints", "title":"Triple Contraints", "description":" on 01/06/12 Project triple constraints are time, cost, and quality. These are the three constraints that control the performance of the project. Think about this triple-constraint as a three-leg tripod. If one of the legs is elongated or", "link2":"http://www.avtainsys.com/articles/Triple_Contraints", "size":"3.3kb" }, { "num":"-1" } ], "other_pages":[ { "title":"1", "link":"search.php?query=constraints&start=1&search=1&results=10&type=and&domain=", "active":"true" }, ] }
The issue is that there is a trailing comma near the end. According to this, "trailing commas are not allowed" when using PHP's json_decode() function. This JSON also failed to parse using this online formatter. But when I took the comma out, it worked and I got this better-formatted JSON:
{
"result_report":"Displaying results 1 - 1 of 1 match (0 seconds) ",
"results":[
{
"idented":"false",
"num":"1",
"weight":"[100.00%]",
"link":"http://www.avtainsys.com/articles/Triple_Contraints",
"title":"Triple Contraints",
"description":" on 01/06/12 Project triple constraints are time, cost, and quality. These are the three constraints that control the performance of the project. Think about this triple-constraint as a three-leg tripod. If one of the legs is elongated or",
"link2":"http://www.avtainsys.com/articles/Triple_Contraints",
"size":"3.3kb"
},
{
"num":"-1"
}
],
"other_pages":[
{
"title":"1",
"link":"search.php?query=constraints&start=1&search=1&results=10&type=and&domain=",
"active":"true"
}
]
}
Now, how would I do this programmatically? And (perhaps more importantly), is there a more elegant way of accomplishing this? And you should know that PHP is the only language I can run on my shared hosting account, so a Java solution for example would not work for me.
In search_result.html, you can surround the , at the end of the foreach loop with condition to only print if the index is strictly less than the number of pages - 1.