How to filter marketplace vehicles with Facebook API - facebook

I am doing /vehicles?limit=300&filter=[{"field":"vehicle_id", "value":"106892", "operator": "EQUAL"}] and then getting error (#100) For field 'vehicles': Param filter must be a valid WCA rule..
==== Query
curl -i -X GET \
"https://graph.facebook.com/v9.0/{catelog_id}/vehicles?limit=300&filter=%5B%7B%22field%22%3A%22vehicle_id%22%2C%20%22value%22%3A%22106892%22%2C%20%22operator%22%3A%20%22EQUAL%22%7D%5D&access_token=<access token sanitized>"
==== Parameters
- Query Parameters
{
"limit": "300",
"filter": "[{\"field\":\"vehicle_id\", \"value\":\"106892\", \"operator\": \"EQUAL\"}]"
}
- POST Parameters
{}
==== Response
{
"error": {
"message": "(#100) For field 'vehicles': Param filter must be a valid WCA rule.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "xxx"
}
}
Facebook Ref: https://developers.facebook.com/docs/marketing-api/reference/product-catalog/vehicles/. I cannot find any clear guide how this filter should be.

The filter field should be a valid JSON-encoded WCA rule expression representing the filter to be applied for the edge. You could find reference for this definition here and here (Filter Rules, se also the Example Filter Rules section). In your example, should be something like:
/vehicles?filter={"vehicle_id":{"eq":"106892"}}

Related

Linkedin Api to delete creative unable to call (getting 500)

Trying to make a call to linkedin api https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-creatives-new?view=li-lms-2022-10&tabs=http#delete-a-creative
to delete a creative however am receiving a 500 error
{
"code": "GATEWAY_INTERNAL_ERROR",
"message": "Gateway Internal Error"
}
body of the request is:
"patch": {
"$set": {
"status": "PENDING_DELETION"
}
}
}
as per the documentation passed the header
X-RestLi-Method
as
DELETE
The issue was field name
"intendedStatus": "PENDING_DELETION"

Content-Language metadata field in GCS object not allowing ISO-639-2 from API

While trying to update the Content-Language metadata field of an object to ISO-639-2 field from the UI works fine, when trying to do the same from http API, it fails with an invalid argument error. The official documentation page states that ISO-639-1 codes are supported (although the link goes to 639-2).
Any ideas on how to update the Content-Language via http/json for objects in ISO-639-2 ? Or it's possible the UI treats it differently?
Response from GetObject for an object with ISO-639-2 updated via ui
{
"kind": "storage#object",
"id": "XXXXXXXXX/textfile.txt/XXXXXXX",
"selfLink": ...,
"mediaLink": ...,
"name": "textfile.txt",
"bucket": "XXXXXX",
"generation": "XXXXXX",
"metageneration": "2",
"contentType": "text/plain; charset=utf-8",
"storageClass": "STANDARD",
"size": "29",
"md5Hash": "f510qpm7Jh30uKbBcN4e0A==",
**"contentLanguage": "ach",**
"crc32c": "4fnpOw==",
"etag": "COet043XpPcCEAI=",
"temporaryHold": false,
"eventBasedHold": false,
"timeCreated": "2022-04-21T07:56:14.769Z",
"updated": "2022-04-21T07:57:14.321Z",
"timeStorageClassUpdated": "2022-04-21T07:56:14.769Z",
"metadata": {
"gcsfuse_mtime": "2022-04-21T07:56:13.375009661Z"
}
}
Error when trying to set the same value as received in the above call via json
{
"error": {
"code": 400,
"message": "Invalid argument.",
"errors": [
{
"message": "Invalid argument.",
"domain": "global",
"reason": "invalid"
}
]
}
}
I reproduced your case, and it seems like you are right. Content-Language only allows ISO 639-1 language codes for the supported values of this metadata.
When Content-Language was set to “ach” in JSON POST API call it gave me errors “curl: (3) Failed to convert ach” to ACE; string contains a disallowed character” but when set to “en”/ “de”/ “aa” it works fine and gives a HTTP 200 response. I think the logic which works here, checks for ISO 639-1 format.
I have gone through the documentation, and it says clearly “Refer to ISO 639-1 language codes for the supported values of this metadata.” Maybe it routes to ISO 639-2 page, because it contains both ISO 639-1 and ISO 639-2 codes, out of which it mentions it only supports ISO 639-1 language codes. You can check out this documentation as well.
Raise a feature request here so that the Content-Language supports ISO 639-2 language code in API calls.

Firestore REST API use with appGyver Composer Pro

I´m trying the new appGyver Composer Pro with Google Firebase (without success). AppGyver uses REST API to get data on the database, but I can´t get it to work.
The database is very simple and has only two documents, so I´m using SoapUI and Postman to try differen uri´s to identify how to set Composer Pro:
So, using GET https://firestore.googleapis.com/v1/projects/{project}/databases/(default)/documents/{collection}/
This is the result of the request:
{"documents": [
{
"name": "projects/{project}/databases/(default)/documents/{collection}/{id}",
"fields": {
"Nombre": {"stringValue": "Cerros"},
"Resolucion": {"mapValue": {"fields": {
"Numero": {"stringValue": "22"},
"Entidad": {"stringValue": "Curaduria"},
"FechaResolucion": {"timestampValue": "2020-04-09T05:00:00Z"}
}}}
},
"createTime": "2020-04-10T13:11:35.364097Z",
"updateTime": "2020-04-10T13:11:35.364097Z"
},
{
"name": "projects/{project}/databases/(default)/documents/{collection}/{id}",
"fields": {
"Nombre": {"stringValue": "Urbanizacion Guayacanes"},
"Resolucion": {"mapValue": {"fields": {
"Numero": {"stringValue": "14"},
"Entidad": {"stringValue": "Municipio de Chinchina"},
"FechaResolucion": {"timestampValue": "2013-11-13T05:00:00Z"}
}}}
},
"createTime": "2020-04-09T14:29:09.633853Z",
"updateTime": "2020-04-09T14:29:09.633853Z"
}
]}
But if I use
https://firestore.googleapis.com/v1/projects/{project}/databases/(default)/documents/{collection}/?Nombre=Cerros
I get
{"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"Nombre\": Cannot bind query parameter. Field 'Nombre' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [ {
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [{"description": "Invalid JSON payload received. Unknown name \"Nombre\": Cannot bind query parameter. Field 'Nombre' could not be found in request message."}]
}]
}}
I get almost the same message (only the name of the field changes) using any of the following instead of ?Nombre=Cerros:
?"Nombre"="Cerros"
?"documents.Nombre"="Cerros"
?"documents.fields.Nombre"="Cerros"
Or using before ? any of the following:
:runQuery
search
What am I doing wrong?
I would really appreciate any help
Eduardo
P.D.
I tried on the REST API Explorer:
curl --request POST \
'https://firestore.googleapis.com/v1/projects/permisos-23395/databases/(default)/documents/Inmueble/:runQuery' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"structuredQuery":{"select":{"fields":[{"fieldPath":"Nombre"},{"fieldPath":"matInm"}]},"from":[{"collectionId":"Inmueble","allDescendants":false}],"where":{"fieldFilter":{"field":{"fieldPath":"Nombre"},"op":"EQUAL","value":{"stringValue":"Cerros"}}}}}' \
--compressed
And got
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"structuredQuery\" at 'document': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document",
"description": "Invalid JSON payload received. Unknown name \"structuredQuery\" at 'document': Cannot find field."
}
]
}
]
}
}
The endpoint you're using is meant for listing the documents of a collection, not for retrieving it's contents.
When you call https://firestore.googleapis.com/v1/projects/{project}/databases/(default)/documents/{collection}/ you're calling the method projects.databases.documents.list which as you saw returns a list of the documents belonging to that collection.
Afterwards you're trying to retrieve the document matching the restriction "Nombre=Cierros" using query parameters while pointing to the list endpoint, which is not a valid request.
If you actually want to retrieve the documents you would need to use one of the following:
To request for a single document you need to use the method projects.databases.documents.get with a get request to the endpoint https://firestore.googleapis.com/v1/projects/{project_id}/databases/{database_id}/documents/{document_path}. Where document path would be of the form {collection}/{documentId}.
To query documents based on a filter you need to use the method projects.databases.documents.runQuery supplying a request body in the format described in the documentation.
Thanks Happy-Monad. I followed your lead and got it to work:
There needs to be an Index by {collection} {query field}, created in addition to the default ones.
Never got it to work with the API EXPLORER, because it needs the collection id on the parent path, but :runQuery does not work if its in there.
:runQuery is requested with a POST call (not GET): https://firebase.google.com/docs/firestore/reference/rest#rest-resource:-v1.projects.databases.documents
The curl call that worked is as follows:
curl --request POST \
'https://firestore.googleapis.com/v1/projects/{database}/databases/(default)/documents:runQuery' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"structuredQuery":{"select":{"fields":[{"fieldPath":"Nombre"},{"fieldPath":"nicInm"}]},"from":[{"collectionId":"{collection}","allDescendants":true}],"where":{"fieldFilter":{"field":{"fieldPath":"Nombre"},"op":"EQUAL","value":{"stringValue":"Cerros"}}}}}' \
--compressed
It returns (JSON):
array [1]
0 {2}
document {4}
name : projects/{database}/databases/(default)/documents/{collection}/{document id}
fields {2}
nicInm {1}
stringValue : 17-00-01-0001
nameInm {1}
stringValue : Cerros
createTime : 2020-04-14T15:22:53.782673Z
updateTime : 2020-04-14T15:22:53.782673Z
readTime : 2020-04-14T16:04:55.392601Z

how to setup “Get started” button in facebook messenger bot

I m trying to use postman
link:https://graph.facebook.com/v6.0/me/messages?access_token=my_token
{
"get_started":{
"payload": "Hi, I am bot"
}
}
in raw JSON body
but getting this response
{
"error": {
"message": "(#100) Tried accessing nonexisting field (messages) on node type (Page)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AtFh2_fJ2sxkeU8k-2aNJGl"
}
}
Here is the little rundown how to put get started button , I hope its help:
Using postman:
Start by changing the type by choosing a POST request: (one of the
problems that solve my issue thanks to #misorude
Define a Post request to this URL:
https://graph.facebook.com/v6.0/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
As #misorude notice my another problem check endpoint from here https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api
In the BODY section:
.
Paste this code:
{
"get_started":{
"payload": "Hi, I am bot"
}
}
P.S.
Thank you again

Cannot delete Facebook some test users

When I call:
$ curl 'https://graph.facebook.com/v2.2/<APP_ID>/accounts/test-users?access_token=<APP_ACCESS_TOKEN>&limit=500'
I see 82 accounts, and all but one look like this:
{
"id": "1413484435585065",
"login_url": "https://developers.facebook.com/checkpoint/test-user-login/1413484435585065/"
}
That is, they have no access token.
When I try to delete them I get:
$ curl -XDELETE 'https://graph.facebook.com/v2.2/1413484435585065?access_token=<APP_ACCESS_TOKEN>'
{
"error": {
"message": "(#100) Invalid value specified for param: id",
"type": "OAuthException",
"code": 100
}
}
The only one that DOES have an access token returns:
{
"error": {
"message": "(#2904) You cannot delete the Open Graph Test User for your app.",
"type": "OAuthException",
"code": 2904
}
}
If I go to Roles...Test Users on the Developers page of the app, then it is empty!
Any new test users I create I can see on the Developers page, and I can delete them using the mentioned curl call.
Where could these test users come from, and how do I get rid of them? Or at least filter them when I am listing test users.