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

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.

Related

OpenAI API call error: we could not parse the 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
"

How do I escape an ampersand in a Socrata SODA 2 API call?

I am working with the NYC crime dataset and I notice that the offense type for homicides is MURDER & NON-NEGL. MANSLAUGHTE. (Yes, that’s “manslaughte” without the “r”.) However, when I try to filter for this using the SODA API, I get errors:
https://data.cityofnewyork.us/resource/hyij-8hr7.json?$where=offense='MURDER & NON-NEGL. MANSLAUGHTE'
{
"error" : true,
"message" : "Unrecognized arguments [ NON-NEGL. MANSLAUGHTE']"
}
It seems to me that the ampersand in the string is escaping.
Note that I tried to use the like=‘MURDER’ command to avoid needing to type the ampersand, so for instance querying https://data.cityofnewyork.us/resource/hyij-8hr7.json?$where=offense like 'MURDER', but this gives me the error
{
"error" : true,
"message" : "Error: function #LIKE is not defined in SoQL.: Error: function #LIKE is not defined in SoQL.”
}
This must mean that the NYC dataset is using SoQL. v. 2.0 and not 2.1.
So in conclusion, how can I query for homicides? Is there a way to either (a) properly escape the ampersand, or (b) search for substrings?
Thanks for any assistance on either of these requests.
You're correct, hyij-8hr7 is the SODA 2.0 endpoint for that dataset. However, a 2.1 endpoint also exists: https://dev.socrata.com/foundry/data.cityofnewyork.us/e4qk-cpnv
Using the 2.1 endpoint, you can escape the ampersand as a URL-encoded %26: $where=offense='MURDER %26 NON-NEGL. MANSLAUGHTE'. Full URL, fully-escaped:
GET https://data.cityofnewyork.us/resource/e4qk-cpnv.json?$where=offense%3D%27MURDER%20%26%20NON-NEGL.%20MANSLAUGHTE%27
With the 2.1 endpoint, you can also use LIKE to do SQL-style substring searches or $q to use the full-text search index.

Simperium Data Dictionary or Decoder Ring for Return Value on "all" call?

I've looked through all of the Simperium API docs for all of the different programming languages and can't seem to find this. Is there any documentation for the data returned from an ".all" call (e.g. api.todo.all(:cv=>nil, :data=>false, :username=>false, :most_recent=>false, :timeout=>nil) )?
For example, this is some data returned:
{"ccid"=>"10101010101010101010101010110101010",
"o"=>"M",
"cv"=>"232323232323232323232323232",
"clientid"=>"ab-123123123123123123123123",
"v"=>{
"date"=>{"o"=>"+", "v"=>"2015-08-20T00:00:00-07:00"},
"calendar"=>{"o"=>"+", "v"=>false},
"desc"=>{"o"=>"+", "v"=>"<p>test</p>\r\n"},
"location"=>{"o"=>"+", "v"=>"Los Angeles"},
"id"=>{"o"=>"+", "v"=>43}
},
"ev"=>1,
"id"=>"abababababababababababababab/10101010101010101010101010110101010"}
I can figure out some of it just from context or from the name of the key but a lot of it is guesswork and trial and error. The one that concerns me is the value returned for the "o" key. I assume that a value of "M" is modify and a value of "+" is add. I've also run into "-" for delete and just recently discovered that there is also a "! '-'" which is also a delete but don't know what else it signifies. What other values can be returned in the "o" key? Are there other keys/values that can be returned but are rare? Is there documentation that details what can be returned (that would be the most helpful)?
If it matters, I am using the Ruby API but I think this is a question that, if answered, can be helpful for all APIs.
The response you are seeing is a list of all of the changes which have occurred in the given bucket since some point in its history. In the case where cv is blank, it tries to get the full history.
You can find some of the details in the protocol documentation though it's incomplete and focused on the WebSocket message syntax (the operations are the same however as with the HTTP API).
The information provided by the v parameter is the result of applying the JSON-diff algorithm to the data between changes. With this diff information you can reconstruct the data at any given version as the changes stream in.

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.

R - Twitter Extraction - Error in .subset2(x, i, exact=exact)

I am making an R-script to get all of the mentions (#username) of a specific set of users.
My first issue isn't a big deal. I try to work at home, as well as work. At work, the code works fine. At home, I get Error 32 - Could not authenticate you from Oauth. This is using the exact same code, key, secret, token. I have tried resetting my secret key/token, same thing. Not a problem, since I can do remote login, but its frustrating.
The REAL issue here...
I construct a URL (ex: final_url = "https://api.twitter.com/1.1/search/tweets.json?q=#JimFKenney&until=2015-10-25&result_type=recent&count=100")
Then I search twitter for my query of #usernameDesired to get all the comments where they were mentioned.
mentions = GET(final_url, sig)
This works fine, but then I want my data in a usable format so I do...
library(rjson)
#install.packages("jsonlite", repos="http://cran.rstudio.com/")
library(jsonlite)
#install.packages("bit64", repos="http://cran.rstudio.com/")
json = content(mentions)
I then get the following error -
$statuses
Error in .subset2(x, i, exact = exact) : subscript out of bounds
I don't have even the first idea of what can be causing this.
Any help is gratly appreciated.
EDIT 1: For Clarity, I get the error when trying to see what is in json. If I do "json = content(mentions)" that line of code executes fine. I then type "json" to see what is in the variable, and I get the above error that starts with $statuses.