Freesound API, POST Request Example Returns Error - html

I've been attempting to program something that interacts with Freesound.org's API, in a way similar to this example given in the Freesound API documentation...
curl -X POST -H "Authorization: Token {{your_api_key}}" -F
analysis_file=#"/path/to/your_file.json"
'https://www.freesound.org/apiv2/search/content/'
... But when I run this with my details replaced, I get this error:
{"detail":"The similarity server could not be reached or some unexpected error occurred."}
I wonder if anybody knows what might might be the cause of this? As no other info is given and I'm not experienced with restfulness etc.
It seems likely to me that the JSON is not formatted properly? But it was generated with precisely the application the documentation refers to in the example I got that code from. This is that JSON:
https://www.dropbox.com/s/kjpf9zzftsxzoar/test.json?dl=0
I'd be very grateful for any help. Cheers.

You can validate your json in online validator like jsonlint.com. And it shows the json content is a valid one.
Do you happen to know what is the error code its returning.

Here's what I'm getting from the request, looking at it in PAW:
https://imgur.com/a/AuIBR

Related

Can I utilize cURL parameters without using cURL?

This is probably a stupid question but I'm pretty out of my depth here. I'm trying to utilize an API for my business, and while most of the API has the parameters in the form of "site?param1=one&param2=two", one of them does not. Instead it's in the form
required parameters -> key
optional parameters
params: a key-value array of where clauses for the query
I would love to be able to put the parameters in directly in the link, but I'm not sure how to parse this or if it's possible.
Example
https://thepetresorts.gingrapp.com/api/v1/animals?key=KEY&params=[{animal_id=1},{name=Charlie}]
This is the example they provided using cURL, but I'm really not interested in actually programming with the API, I just need to make specific pulls every once in a while, and I cannot for the life of me figure out how to utilize cURL.
curl "https://{your-subdomain-here}.gingrapp.com/api/v1/animals" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
--data-urlencode "params[month(from_unixtime(birthday))]=11" \
--data-urlencode "key={your-key-here}"
Any advice would be extremely appreciated!
If you're working with an API, it's even better if you can use POSTMAN or INSOMNIA.
The API your describing has two types of requests, GET and POST - the GET request is usually used to "get to view" but occasionally some use it to also modify and push data - this uses parameters within the URL (what you described), POST however is generally used to push data into the body to make a modification, the parameters are posted within the body of the request instead of in the actual URL like GET requests.
You won't be able to modify the endpoint (unless its your own) you will need to GET where its needed and POST when its needed, the POST request will likely deny a GET request as it's not the intended method - you can create a jump page (your own API) to accept GET parameters and generate a POST request to your API - as #muklis mentioned POSTMAN is great you can create the request in there, generate the code in any language and use that to produce a simple PHP page or so that'll take in $_GET[] variables and pass them into the generated POSTMAN request - it's probably your best bet.
-- Edit
You can also use Zapier, forgot about that - Zapier is amazing for easy code-less integrations; you can use the Webhook zap to receive your parameters in repost them in two easy steps within the zap.
Just another idea for you.

Why I am getting insufficient scope error by posting json through postman?

I have added headers and token but still having insufficient_scope error by posting json through postman
You must share the details of request to get help. But let me also try to help you out blindly.
I had face the same issue in past and make it possible to resolve the issue by some simple attempts.
Please make sure that your token is correct, its not expired, and if your token is well authorized to make request and get access of the demanding resources from the calling API.
Also make sure that if you have need to add bearer in the start of your token.
Hope it can solve your related issue. Thank You!
Also, check your request method. (I just spent a good 30 minutes trying to figure out why I was failing.) If you have only the listings_r scope, then you can only GET. You must have listings_w to POST. (My problem was copy/pasting several lines of cURL code, and I assume someone else reading this may have done the same.)

get all channel info with youtube api and curl

Hey guys i was perusing the youtube api documents and saw this json snippet right here: https://developers.google.com/youtube/v3/docs/channels#resource-representation
I saw this and would like to grab all this info from the specified youtube channel in my curl code. So far all i wrote was this:
curl "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[CHANNEL NAME]&key=[API KEY]"
but that only gives back a small part of that json, i think its the "statistics" part.
If yall can help that would be so kind, thanks.
To get the other info attached to a given channel, do mention the set of properties you're interested in via the part parameter, as specified by the reference doc.
Update:
To get all the info available, the URL to be passed to curl would be:
https://www.googleapis.com/youtube/v3/channels?part=brandingSettings,contentDetails,contentOwnerDetails,id,localizations,snippet,statistics,status,topicDetails&id=[CHANNEL NAME]&key=[API KEY]
Note that the part parameter does not contain auditDetails since that requires additional permissions.

Unable to get accurate results from Browserlocation API with curl

I'm trying to get the current location of my computer from Google's BrowserLocation API.
How to create a script to query Google Browserlocation: This thread helped me construct the script, but one problem remains: the accuracy is way off when using curl from the command line: "accuracy" : 11178. Bafflingly, if I copy-paste the same address in my browser, the returned JSON is perfectly fine with an accuracy of "accuracy" : 52.
What could the crucial difference be, and how do I modify the curl script to work like my browsers do? There is JSON, CURL and Google's geolocation this previous thread with what appears to be a similar issue, but the solution posted does not help me.
I have Wireshark, and a capture of the two methods of accessing the API. I am currently trying to figure out how to retrieve the relevant packets for inspection. If anyone can help me with this intermediate step, that would be most welcome.
Well I got it to work. The issue was that I didn't URL escape the names of the access points. Look here for how to do this with Perl.

Direct POST into URL not working?

I am trying to contact an API by posting the parameters in the URL. I am unsure whether it will respond in XML or JSON, but it is one of the two, however, it says there is an error.
This is an example of what I'm submitting. I am receiving this in response:
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.
I do not know what is going on... I followed the syntax of the POST I believe, my only remaining question about the syntax would be whether the ? is in the right spot. The page API does work when I POST using PHP...
Or maybe it is working, the browser just isn't capable of understanding an XML or JSON response? (I'm using chrome so I do not think this is the issue)
Otherwise, if anyone has any insight on this, I'd be greatful
A different browser yields this error:
XML Parsing Error: syntax error
Location:
Line Number 1, Column 1:Array
^
While the syntax of the URL does seem to be fine, you imply that the API expects the parameters in POST. Adding them to the actual URL means the parameters are passed in GET, rather than POST.
You could try to test this by making a little HTML form containing all the relevant parameters and passing them to this API via POST, and see if that gives you the expected result.
your issue is how their being sent to the api it should be url-encoded
http://api.example.com/api/?apikey=asdfa23462=example&ip=208.74.76.5
should be
http://api.example.com/api/?apikey=asdfa23462&=example&ip=208.74.76.5
also another issue i see is that you have ?apikey=asdfasfsdafsd&=example
the =example could well be the issue all together.
just some thoughts from what i see.