I'm sending push notifications from a rails app through the parse.com REST API.
Targeting a single user works great but targeting more users with $in doesn't seem to work in my scenario.
Here's my JSON Code:
{
"where":
{
"user":
{
"__type":"Pointer",
"className":"_User",
"objectId":
{
"$in":["AAA","BBB","CCC"]
}
}
},
"data":
{ ...
Isn't it possible to use $in when targeting multiple users? I noticed that I'm also not able to to so in the parse.com push backend.
The response is:
{
"code": 106,
"error": "key objectId should be a string"
}
Anyone got an idea? I don't want to make an separate REST Call for every notification.
Okay, sorry I found the answer here: REST in Parse $in to ObjectID of Pointer Error Code 106
Or in short, this code works:
{
"where":
{
"user":
{
"$inQuery":
{
"where": {
"objectId":
{
"$in":["AAA","BBB","CCC"]
}
},
"className":"_User"
}
}
},
"data":
Related
I have a single request "auth" that simply sends the below raw data..
{
"password": "123",
"userName": "rob"
}
and i have setup two examples. The first called "success" takes the above request and returns..
{
"user": {
"profile": 1234
}
}
I then wanted to test scenario whereby the password (and eventually user name) is empty so i can see error being returned. So a second example "No Password" sends
{
"password": "",
"userName": "rob"
}
and the response is
{
"id": {
"code": 1
},
"errorObject": [
{
"errorCategory": "INPUT_ERROR",
"errorName": "PWRD_EMPTY",
}
]
}
Now the issue is that regardless of what request i make i always get back the error response. I've tested this a few times and i think it's actually just returning whatever the newest example created was.
Is Postman able to detect differences in json data in the request body? I have tried creating a second "auth" request, one for success scenario and the other for the failure but this didn't resolve the issue.
I am trying to parse multiple translations in Talend using a tExtractJSONFields component. I am not that familiar with XPath.
{
"data": {
"translations": [
{
"translatedText": "Bonjour"
},
{
"translatedText": "Au Revoir"
}
]
}
}
When I am only translating a single element, this configuration works:
However when I am requesting multiple translations, I am trying to guess at the syntax to pull out the different translatedText values in the response.
For example, this doesn't work it seems:
Any help appreciated. I am sending 4 items for translation so expect an array of 4 JSON objects each with a "translatedText" property.
Updated:
Response with 4 items is as below:
{
"data": {
"translations": [
{
"translatedText": "Product 1"
},
{
"translatedText": "04/12/1984"
},
{
"translatedText": "Withdrawn"
},
{
"translatedText": "national"
}
]
}
}
When I try this:
I get close, but all the output looks like it has square brackets around it indicating an array of sorts.
And I have tried the above with "translations[0]/translatedText[0]" as the XPath query and it does the same thing.
Actually this seems to have worked:
I want to 'get' just the first tier information from my firebase JSON via the REST api, without any of the nested arrays each object has. How can I do that with firebase, to avoid having to download the entire dataset?
i.e. from the JSON below I just want to return:
{ "people":[
{"name":"bob"},
{"name":"dave"}
]}
Full data
{
"people":[
{
"name":"bob",
"measurements":[
{
"measname":"first test",
"weights":[
{
"device":"scaleA",
"weight":78.0
},
{
"device":"scaleA",
"weight":78.2
}
]
}
]
},
{
"name":"bob",
"measurements":[
{
"measname":"first test",
"weights":[
{
"device":"scaleA",
"weight":78.0
},
{
"device":"scaleA",
"weight":78.2
}
]
}
]
}
]
}
Edit: I didn't realize you specified this needed to be server-side. According to this question, it doesn't seem to be possible: Database-style Queries with Firebase
I'm trying to Target company shares (https://developers.linkedin.com/documents/targeting-company-shares) using json with LinkedIn Rest Api.
My JSON object (https://developers.linkedin.com/forum/targeting-example-using-multiple-targeting-parameters-and-json) looks like :
{
"visibility": {
"code": "anyone"
},
"comment": "Targeting Shares",
"share-target-reach": {
"share-targets": {
"share-target": [{
"code": "geos",
"tvalues": {
"tvalue": "as"
}
}, {
"code": "companySizes",
"tvalues": {
"tvalue": "201-500"
}
}]
}
}
}
But this isn't working, i'm getting the following error :
{
"errorCode": 0,
"message": "Malformed json document. Encountered unexpected array.",
"requestId": "DRWYRUVMBJ",
"status": 400,
"timestamp": 1423283491818
}
I'm not able to figure out where's the problem??
I have been playing around with this for awhile now and near as I can tell the below format will work. Basically you have to remove all the arrays, I have tried them at every level and they always cause the malformed json error. I still have no idea how to target multiple sections at once though, since the official documentation on this is very wrong. The only way I figured this part out is by doing a whole lot of guessing.
{
"visibility": {
"code": "anyone"
},
"comment": "Targeting Shares",
"share-target-reach": {
"share-targets": {
"share-target": {
"code": "geos",
"tvalues": {"tvalue": "as"}
}
}
}
I have the following JSON;
{
"b2c": {
"languages": {
"de": {
"models": {
"t300": {
"name": "Aveo",
"bodyTypes": {
"t300-4d-my13": {
"trimLevels": {
"lt": {
"name": "LT",
"variants": {
"1.2_16V_86_Gas_MT": {
"name": "1.2 MT",
"price": {
"EUR": {
"value": 13990,
"formatted": "13.990,00 €"
}
},
"infoFeatures": {
"fuel_consumption_extra_urban#consumption": {
"name": "Kraftstoffverbrauch außerorts ",
"value": "4.6",
"formatted": "4,6"
},
"top_speed#kilometer_per_hour": {
"name": "Höchstgeschwindigkeit",
"value": "171",
"formatted": "171"
}
},
"images": null,
"documents": null
}
}
}
}
}
}
}
}
}
}
}
}
The values of b2c, de, t300, t300-4d-my13, It etc.. are dynamic but languages, models, bodyTypes, trimLevels, variants, inforFeatures, images and documents would remain same.
I need to extract all to access values like languages.["de"], models.["t300"].name, timeLevels.["It"], Variants and infoFeatures, as these keys [""] are dynamics so I am not sure what to refer.
I have tried,
var jsonSerializer = new JsonSerializer();
dynamic dynamicObject = jsonSerializer.Deserialize(new JsonTextReader(new StringReader(jsonString)));
//var level1 = dynamicObject.b2c
I have looked this as well
Deserialize JSON into C# dynamic object?
and tried
var dynamicObject = Json.Decode(jsonString);
but receiving following error;
Attempt by method 'System.Web.Helpers.Json.Decode(System.String)' to access field 'System.Web.Helpers.Json._serializer' failed.
For us it helped to uncheck "Enable the Visual Studio hosting process" in the Project properties > Debug tab, from the top answer to Attempt by method 'System.Web.Helpers.Json..cctor()' to access method 'System.Web.Helpers.Json.CreateSerializer()' failed
A general solution would be to use something like Json.net and serialize to C# Object - this is very flexible, and does not conflict with the dynamic nature of the json object coming from the client.
This error seems to occur when you have multiple projects with different versions of assemblies; eg, if you have JSON.NET 4.5.1 in one project and 5.0.6 in another. Things seem to get sorted if you make sure the same versions exist everywhere in the solution.