I have some place data in parse database.
I would like to use retrofit to find closet place to given lat and longitude
Below is the link , and curl request.
https://parse.com/docs/rest/guide#geopoints-geo-queries
curl -X GET \
-H "X-Parse-Application-Id: xxxxxx" \
-H "X-Parse-REST-API-Key: xxxxx" \
-G \
--data-urlencode 'limit=10' \
--data-urlencode 'where={
"location": {
"$nearSphere": {
"__type": "GeoPoint",
"latitude": 30.0,
"longitude": -20.0
}
}
}' \
How can i convert above curl to retrofit call ?
I think i have to use QueryMap somewhere , but cannot figure out where.
This is what i have so far.
#GET("/classes/Place")
void getPlaces(#Query("limit") Integer limit,
Callback<PlacesResult> callback);
This is request with headers "X-Parse-Application-Id: xxxxxx", "X-Parse-REST-API-Key: xxxxx" and form url encoded body with #Query("where") that takes up string.
You can put these headers in http call Interceptor for all requests.
Yes, this can be done with QueryMap, which will be of two query params.
Related
I'm trying to insert new record with createdAt date provided:
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-Master-Key: ${MASTER_KEY}" \
-H "Content-Type: application/json" \
-d '{"objectId": "xdH402yd9z", "field": "testData", "createdAt": {"__type": "Date", "iso": "2020-05-23T12:26:17.548Z"}}' $URL
Parse Server accepts the request, however it overrides createdAt date with current date.
What am I missing? Is there a server setting or request flag?
I assume the same answer would apply for updatedAt field.
Thank you.
I am unable to get a good response, and having hard time finding Docs. Can't find a way to lookup the inner error code at all either. I get a token using
curl -L -X POST 'https://login.microsoftonline.com/51bcb6e4-b738-4e87-a795-768e3f13b94f/oauth2/v2.0/token' \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id=5bbd5786-31d3-4d84-a8d0-a0dac6522f93' \ --data-urlencode 'scope=https://graph.microsoft.com/.default' \ --data-urlencode 'client_secret=<secret>' \ --data-urlencode 'grant_type=client_credentials'
and then take the access_token value, and do this
curl -L -X GET 'https://graph.microsoft.com/v1.0/teams/d89133ea-bf32-4957-8300-aa5e083f45c1/channels/19:5b075a993aee4b3fa8f23be2cbb3b514#thread.skype/messages' \ -H 'Authorization: Bearer <token value from above>'
But I get this error 403:
{ "error": { "code": "UnknownError", "message": "", "innerError": { "date": "2021-03-09T19:15:23", "request-id": "c9a8cf3a-b914-44a8-a66a-506634f09d77", "client-request-id": "c9a8cf3a-b914-44a8-a66a-506634f09d77" } } }
how can I troubleshoot? the url for the GET seems right, based on all my research. we are using resource specific consent permissions, but the app is installed in the channel that I am trying to list messages. from
This question will be tracked from here.
How can I use the Parse REST API to push to a specific deviceToken or installation Id? I make the request and it succeeds with a 200 response but I get no push.
curl -X POST \
-H "X-Parse-Application-Id: XYZ" \
-H "X-Parse-REST-API-Key: FOO" \
-H "Content-Type: application/json" \
-d '{
"where": {
"deviceToken": "someId"
},
"data": {
"alert": "Willie Hayes injured by own pop fly."
}
}' \
https://api.parse.com/1/push
I have a class A that has a pointer (pointer field) to the special class User. Is it possible to automatically update the pointer field with the authenticated user, using the Rest API instead of having to call the API like the example bellow?
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "X-Parse-Session-Token: ${SESSION_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"user":{ "__type": "Pointer", "className": "_User", "objectId": "${id}"}}' \
https://api.parse.com/1/classes/A
I would like to update the User field by just using the call:
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "X-Parse-Session-Token: ${SESSION_TOKEN}" \
-H "Content-Type: application/json" \
https://api.parse.com/1/classes/A
And an A entry would be created.
A : {Pointer<_User> user_from_session, string objectId}
Any enlightenment is appreciated.
Cheers.
I've managed to accomplish what I wanted by adding an afterSave trigger. When creating A, with an authenticated request, I will read the current user from the session and set the field in the class. Bellow the example.
Parse.Cloud.afterSave("A", function (request, response) {
var record = request.object;
var user = Parse.User.current();
if (record.existed() == false) {
record.set("user", user);
record.save().
then(function (record) {
response.success();
}, function (error) {
response.error();
});
} else {
console.log("[DEBUG] Normal save (A).");
response.success();
}
});
Cheers.
Why can't I add objects using Parse batch bulk import API?
curl -X POST \
-H "X-Parse-Application-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "X-Parse-REST-API-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type: application/json" \
-d '{
"requests":[
{
"method":"POST",
"path":"1/classes/Store",
"body":{
"storeNumber":3466,
"storeLocation":{
"__type":"GeoPoint",
"latitude":-88.481369,
"longitude":44.263837
},
"storeAddress":"4733 W. GRANDE MARKET DR. GRAND CHUTE WI 54913 US"
}
},
...
{
"method":"POST",
"path":"1/classes/Store",
"body":{
"storeNumber":119,
"storeLocation":{
"__type":"GeoPoint",
"latitude":-122.171134,
"longitude":37.444756
},
"storeAddress":"165 STANFORD SHOPPING CTR PALO ALTO CA 94304-1409 US"
}
}
]
}' \
https://api.parse.com/1/batch
{"code":107,"error":"Method 'POST' to '1/classes/Store' not supported in batch operations."}
I have created a 'Store' object with matching column names/types but can't any any rows with the batch API.
From looking at the documentation I would guess it is because your path is invalid.
You need an extra "/" at the front, so /1/classes/Store instead of 1/classes/Store.