Filter in GET with loopback - loopbackjs

I am trying to GET users with a specific filter (such as the email is equal to "e#e.e").
The description says Filter defining fields, where, include, order, offset, and limit - must be a JSON-encoded string ({"something":"value"}), however typing {"email":"ju#ju.ju"} simply gets all the users instead of just this one.
What am I doing wrong?

You should post your query url which looks something like this: http://localhost:3000/api/Model?filter=%7B%20%22where%22%3A%20%7B%22name%22%3A%20%22icecream%22%7D%20%7D
But if I had to guess, you aren't using a filter or where key in your object.
{"filter": {"key": "value"} } incorrect
{"where": {"key": "value"} } correct for the api explorer (because it puts filter there for you), incorrect for anything else
{"filter": {"where": {"key": "value"} } } correct

Related

How to provide updateMask during Google People update contact?

If I need to update the name or address of a contact, giving the field as "names, addresses" works.
How do I need to give the updateMask to update a specific field like "middleName" alone.
Providing updateMask as "names.middleName" does not work and throws the following error:
{
"error": {
"code": 400,
"message": "Invalid updatePersonFields mask path: \"names.middle_name\". Valid paths are documented at https://developers.google.com/people/api/rest/v1/people/updateContact.",
"status": "INVALID_ARGUMENT"
}
}
Anyone help?
Answer:
You need to use names as updatePersonFields, but all names need to be specified. This may be a bug, as linked below, but it is also not clear from the documentation.
More Information:
It is possible this is a bug, though until a response is obtained from the issue tracker report (which I assume was you -but if not - hit the star to help it gain more attention) about this it is not possible to know for sure.
While FieldMasks do accept sub-fields, these are not specified on the updatePersonFields documentation page, only the broader names.
You can see the list of definitely supported fields here under the Query Parameters.
Current Workaround:
While waiting for Google to respond to the bug report, the only way you can get around this is by using the names field mask, but also including the firstName and lastName parameters too when making the patch:
{
"names": [
{
"givenName": "Rafa",
"middleName": "Guillermo",
"familyName": "Rocks"
}
],
"etag": "%XxXXXx00XxxXXXXXXxXXXX00XXXXXXxXxxX0"
}
Remember: If you leave out any of these fields this is tantamount to replacing it with empty string - so be careful!

Facebook-marketing api - need access to type of creative format

I have a requirement in which I need to access the creative format type for each adCreative.
I explored the API and figured that this information is stored in Ad Creative Object Story Spec, however, I am not able to query this object.
This is the request I am making
https://graph.facebook.com/v2.11/<account_id>/adcreatives?fields=id,adset_id,name,creative,image_crops,object_story_id,image_url,image_hash,object_type,object_id,object__story_id,object_url&limit=500&access_token=<access_token>
This is not returning object_story_id and object_story_spec field only.
What am I missing here?
Thanks in advance.
Request those fields on the adcreative edge itself. ie your first call will return a list of adcreative ids.
{
"data": [
{
"id": "23842732907210427"
},
{
"id": "23842732907020427"
}]}
So you would call graph.facebook.com/23842732907210427?fields=object_story_id&access_token=USERACCESSTOKEN to retrieve the spec for that ad creative.
You can also nest queries so you may be able to retrieve the spec in a single call but I have been unsuccessful attempting this. https://developers.facebook.com/docs/graph-api/using-graph-api

Facebook Graph Api Get tagged comments

I am trying to gather information about the number of comments from a facebook past that include a tag to a user, i.e. when you type #Joe Bloggs.
I know you can get all comments by either getting using the Comments edge for a post v2.8/[Postid]/comments or by the comment id directly v2.8/[comment-id]
But the message field that is returned is plain text and includes no indication of tags. e.g. something like:
{
"created_time": "2017-02-28T09:31:08+0000",
"from": {
"name": "Fred Bloggs",
"id": "123"
},
"message": "Joe Bloggs look at this",
"id": "1234"
}
Is it possible to get this somehow?
You need to include the field message_tags in your request. It will give you an array of profiles tagged in this comment.

PUT to an array in existing collection

The following is the schema of my API end-point. I want to test a PUT using PostMan, where I add a "skill".
How would you enter the information in Postman so that you are just passing a new "skill" to the model?
{
"_id": "579a6fa26a0b6484172ae284",
"firstname": "Max",
"lastname": "Headron",
"skills": [
{"skill":"Can Type", "level":"Great"},
{"skill":"Can Run", "level":"Good"},
]
}
Would you use dot notation in a form field. So instead of adding "firstname", which is at the top level of the object, you might enter "skills.skill" and the "value".
Hopefully this is a clearer description.
Just change the body of the request.
See https://www.getpostman.com/docs/requests.

Understanding id returned by Facebook search

If in a web browser I enter:
https://graph.facebook.com/search?q=watermelon
the data returned begins:
{
"data": [
{
"id": "100000079215099_345415575486050",
"from": {
"name": "Synthia Stephen",
"id": "100000079215099"
},
My question relates to the id field. The value returned contains two numbers separated by an underscore character.
1) I believe the first number (100000079215099) is the id of a facebook user, is this always the case?
2) What does the second number (345415575486050) represent?
3) Once I have the full id (100000079215099_345415575486050) is it possible to use this id in another Facebook Graph API to retrieve the data associated with this id? If so, what would that url look like?
On facebook Evry user has ID and every event associated with it may be a status or photo also has an ID.
100000079215099_345415575486050
The first part of it represents the user id and second part represents the Event(Activity like a status or post) Id.
To Understand Better go to https://developers.facebook.com/graph-academy
Answers to your question:
1) First one will always be user id.
2) Mentioned above this is specific event related id. (Status or pic)
3) Yes, you can use this id everywhere in other APIs.
1) Yes the first number is the ID.
2) I'm not sure, I think it may be something to track where the view came from and who the viewer is. Perhaps an access token.
3) https://graph.facebook.com/100000079215099
https://graph.facebook.com/100000079215099_49874987249823749283
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: 100000079215099_49874987249823749283",
"type": "OAuthException"
}
}
https://graph.facebook.com/100000079215099_345415575486052
false
https://graph.facebook.com/100000079215099
returns her data, but I'm omitting it