Get JSON data from Parse.com database using HTTP request - json

I am new to Parse.com and have some data stored in my database class (musical_data).
Is it possible to send a get request in my browser and have it return JSON to me? I have tried to retrieve the data, but can't figure out how to display the database class data in JSON via my browser.
Thanks
Example, this CURL form works.. But I want to type it into the browser url bar.
curl -X GET \
-H "X-Parse-Application-Id: wfwefwefwef" \
-H "X-Parse-REST-API-Key: wefwefwe123" \
https://api.parse.com/1/classes/musical_data

This format should work in the browser:
https://APPID:javascript-key=JSKEY#api.parse.com/1/classes/musical_data
Replace APPID with your application id and replace JSKEY with your JavaScript key

Related

Is there a possibility to scrape an entire job offering database?

I am trying to automatically retrieve all active job listings from Deutsche Telekom from the following website: https://telekom.jobs/global-careers
At the moment, there are 1,813 job offerings.
There seems to be an API that returns JSON code (https://telekom.jobs/globaljobboard_api/v3/search/), however the results are limited to 10 (SearchResultCount).
Is there any possibility to parse some parameters to the API so it returns a JSON file with all 1,800 current job offerings?
Thanks
I have tried to add some parameters to the URL, however I was not succesfull with it
https://telekom.jobs/globaljobboard_api/v3/search/%7B%22JobadID%22:%22%22,%22LanguageCode%22:%222%22,%22SearchParameters%22:%7B%22FirstItem%22:1,%22CountItem%22:10000,%22Sort%22:[%7B%22Criterion%22:%22FavoriteJobIndicator%22,%22Direction%22:%22DESC%22%7D],%22MatchedObjectDescriptor%22:[%22ID%22,%22PositionTitle%22,%22ParentOrganization%22,%22ParentOrganizationName%22,%22PositionURI%22,%22PositionLocation.CountryName%22,%22PositionLocation.CountrySubDivisionName%22,%22PositionLocation.CityName%22,%22PositionLocation.Longitude%22,%22PositionLocation.Latitude%22,%22PositionBenefit.Code%22,%22PositionBenefit.Name%22,%22FavoriteJobIndicator%22,%22FavoriteJobIndicatorName%22]%7D,%22SearchCriteria%22:[%7B%22CriterionName%22:%22PositionLocation.Latitude%22,%22CriterionValue%22:[%2250.73743%22]%7D,%7B%22CriterionName%22:%22PositionLocation.Longitude%22,%22CriterionValue%22:[%227.098206800000071%22]%7D,%7B%22CriterionName%22:%22PositionLocation.Distance%22,%22CriterionValue%22:[%229.013064227023515%22]%7D,%7B%22CriterionName%22:%22PositionLocation.CountryCode%22,%22CriterionValue%22:[%22DE%22]%7D,%7B%22CriterionName%22:%22PositionLocation.AreaCode%22,%22CriterionValue%22:[%22DE%22]%7D]
My expected results are a JSON file of the whole database, not only the ten most recent entries.
You need to do a POST with the data {"SearchParameters":{"CountItem":1813}}.
Here an example using curl:
curl 'https://telekom.jobs/globaljobboard_api/v3/search/' -H 'Accept: application/json' --compressed -H 'Content-Type: application/json' --data '{"SearchParameters":{"CountItem":1813}}'
Notice this is particular to this API, this will not necessarily work for others.

webapp2 how to access PUT data

I am using webapp2 to make a small api.
So for example if I have:
import webapp2
class Test(webapp2.RequestHandler):
def put(self):
self.response.write("this was a test")
app = webapp2.WSGIApplication([
('/test', Test)
])
And I do a request through curl:
curl --request PUT --header "Content-Type: application/json" --data '{"content": "test"}' http://localhost:8080/test
How would I go about accessing the data '{"content": "test"}' that was passed in?
All request data would be somewhere in self.request, so in this case take a look at self.request.body to find the request's contents and check out the documentation's Common Request attributes section to see the rest of the options.
You may also want to consider looking at the entire self object in a debugger to find out about more interesting properties it has.

trying to retrieve one object based on conditions values using Android REST API

I’m using Parse.com, and trying to retrieve one object based on conditions values using Android REST API
here is a snippet from the Parse documentation for the REST API
curl -X GET \
-H "X-Parse-Application-Id: MYAPPID" \
-H "X-Parse-REST-API-Key: MYRESTKEY" \
-G \
--data-urlencode 'where={"$relatedTo":{"object":{"__type":"Pointer","className":"Post","objectId":"8TOXdXf3tz"},"key":"likes"}}' \
https://api.parse.com/1/users
How can I achieve this in android?
It's curl based api, you have to explicitly pass all its parameter.
I recommending you to first test api using client application like Postman.
-X define term like GET,POST,PUT,DELETE
-H define header, which has key-value form data separated by ":" sign.
-G When used, all data to be used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
Pass all these parameters and test it, once it is working fine then implement to your application.

POST: sending a post request in a url itself

I have been given a url .. www.abc.com/details and asked to send my name and phone number on this url using POST. They have told me to set the content-type as application/json and the body as valid JSON with the following keys:
name: name of the user
phone number: phone number of the user
Now i have no clue how to send this request! Will it be something like:
http://www.abc.com/details?method=post&name=john&phonenumber=445566
or do i have to use java to send the same?
Please help
Based on what you provided, it is pretty simple for what you need to do and you even have a number of ways to go about doing it. You'll need something that'll let you post a body with your request. Almost any programming language can do this as well as command line tools like cURL.
Once you have your tool decided, you'll need to create your JSON body and submit it to the server.
An example using cURL would be (all in one line, minus the \ at the end of the first line):
curl -v -H "Content-Type: application/json" -X POST \
-d '{"name":"your name","phonenumber":"111-111"}' http://www.example.com/details
The above command will create a request that should look like the following:
POST /details HTTP/1.1
Host: www.example.com
Content-Type: application/json
Content-Length: 44
{"name":"your name","phonenumber":"111-111"}
You can post data to a url with JavaScript & Jquery something like that:
$.post("www.abc.com/details", {
json_string: JSON.stringify({name:"John", phone number:"+410000000"})
});
It is not possible to send POST parameters in the URL in a straightforward manner. POST request in itself means sending information in the body.
I found a fairly simple way to do this. Use Postman by Google, which allows you to specify the content-type (a header field) as application/json and then provide name-value pairs as parameters.
You can find clear directions at [2020-09-04: broken link - see comment] http://docs.brightcove.com/en/video-cloud/player-management/guides/postman.html
Just use your URL in the place of theirs.
You can use postman.
Where select Post as method.
and In Request Body send JSON Object.
In windows this command does not work for me..I have tried the following command and it works..using this command I created session in couchdb sync gate way for the specific user...
curl -v -H "Content-Type: application/json" -X POST -d "{ \"name\": \"abc\",\"password\": \"abc123\" }" http://localhost:4984/todo/_session
If you are sending a request through url from browser(like consuming webservice) without using html pages by default it will be GET because GET has/needs no body. if you want to make url as POST you need html/jsp pages and you have to mention in form tag as "method=post" beacause post will have body and data will be transferred in that body for security reasons. So you need a medium (like html page) to make a POST request. You cannot make an URL as POST manually unless you specify it as POST through some medium. For example in URL (http://example.com/details?name=john&phonenumber=445566)you have attached data(name, phone number) so server will identify it as a GET data because server is receiving data is through URL but not inside a request body
In Java you can use GET which shows requested data on URL.But POST method cannot , because POST has body but GET donot have body.

How to send headers from YQL in order to return JSON format when querying opendatabc API?

I'm wondering if there is a way to send headers from YQL (or the YQL console) like there is in cURL.
I would like to return JSON by specifying the header Accept: application/json.
I am able to return JSON in with cURL and the command line like this:
curl -H 'Accept: application/json' http://www.opendatabc.ca/data?=births
but I can't figure out how to set the header when sending YQL.
You can do this with YQL Open Data Tables.
Here is a simple demonstration.
You can find the gist for the example Open Data Table XML file here: https://gist.github.com/2042904 (Check out the documentation here.)
You will notice in my example XML that I'm using y.xmlToJson on the response object received from the get() request. This is because YQL converts JSON taken from web services into E4X. More about that in a question of mine.
You should use format parameter when querying YQL over API, instead of headers. Either by format=json or format=xml.
JSON example:
curl -G --data-urlencode 'q=SELECT * FROM html WHERE url = "example.com"' http://query.yahooapis.com/v1/public/yql?format=json
XML example:
curl -G --data-urlencode 'q=SELECT * FROM html WHERE url = "example.com"' http://query.yahooapis.com/v1/public/yql?format=xml
use "jq", if have not installed it yet, run this command first
sudo apt-get install jq
then you can curl your url like this
curl -H 'Accept: application/json' http://www.opendatabc.ca/data?=births | jq '.'