I'm following this tutorial https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/#send_a_request_from_the_command_line_for_fcm_to_push_a_message
I did everything as is instructed there so far. However when I do a curl request I get back
{"multicast_id":6771552758811002436,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
I checked it billion times I have put correct senderId in my manifest.json in "gcm_sender_id"
So why would I get such error?
Here are some more details.
In the tutorial it says to get the keys from FCM console in cloud messaging
This is how my manifest.json looks like
{
"name":"Push Notifications codelab",
"gcm_sender_id":"773185791049"
}
And this is how I send the request
curl --header "Authorization: key=AIzaSyCQHb2t8c3N255bH_CVmGych5QcNntFxYg" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"APA91bE4RJ7_9m2eJ_zlg1F90bLjVX8ctVpCBN24ElAXF--4wS_nnxg4LzkbJWeTe-peMN_StmOaQTEoGeCCNZE5Mssux3T-KbfGRVmRWzeQZM8opfUyv7FVjI9iEfETHG3O7i1qkIb-\"]}"
Related
I'm running my local emulator suite and I'm constantly getting error messages for my curl requests. The following command:
curl -X POST http://localhost:5001/my-project/us-central1/myFunction \
-H "Content-Type: application/json" \
-d '{"productId": 123456, "quantity": 100}'
Is always showing this in the emulator CLI:
> {"productId":123456,"quantity":100,"severity":"WARNING","message":"Request body is missing data."}
> {"severity":"ERROR","message":"Invalid request, unable to process."}
None of the code was executed in the function as it starts with a console log which is never printed here. Any thoughts?
That error occurs when you use the onCall method. So, I would assume that you are using functions.https.onCall. As explained in this documentation:
It's important to keep in mind that HTTPS callable functions are similar but not identical to HTTP functions. To use HTTPS callable functions you must use the client SDK for your platform together with the functions.https backend API (or implement the protocol).
If you want to directly call the function via its endpoint then you should follow the protocol specification for https.onCall. One of its requirements is the request body should be a JSON object with data as its main key.
An example request JSON object should be like this instead:
{
"data": {
"productId": 123456,
"quantity": 100
}
}
For reference, here's the full curl request:
curl -X POST http://localhost:5001/my-project/us-central1/myFunction \
-H "Content-Type: application/json" \
-d '{ "data": { "productId": 123456, "quantity": 100 } }'
For more information, you may check out this documentation:
Protocol specification for https.onCall
I am trying to upload an image to my personal page through the new v2 LinkedIn API.
I am using curl request as shown below :
curl -i --upload-file ~/Desktop/Myimage.jpg -H 'Authorization: Bearer Redacted' "https://api.linkedin.com/mediaUpload/C5522AQHn46pwH96hxQ/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLKRJOn_yNw6wAAAW2T0DWnRStny4dzsNVJjlF3aN4-H3ZR9Div77kKoQ&app=1983914&sync=0&v=beta&ut=1Dnjy796bpjEY1"
After hitting this command on the terminal , I am getting the response: "52 “empty reply from server”.
Please suggest how to resolve this error or what should I use in PHP to upload assets in Linkedin instead of curl?
I am trying to access my Firestore database using cURL from a terminal session. I have read through the REST API documentation for Firestore and the Authentication documentation for authenticating Oauth and services accounts. I have set up a services accounts and IAM roles in API dashboard. I cannot determine from the documentation what the correct path and syntax and what do use for the API Key and the BEARER token. For example, I am trying to receive a json response for the USER xyz, document field FNAME that is stored in a Firestore DATABASE (note - where do i find the the databaseID?) that is in PROJECT testproject.
Here is the CURL command lists in the documentation -
curl \
'https://firestore.googleapis.com/v1beta1/%5BNAME%5D?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
curl --request POST \
'https://firestore.googleapis.com/v1beta2/%5BNAME%5D:exportDocuments?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{}' \
--compressed
Questions are - what do I use for the [YOUR_API_KEY] ?
What do I use for the [YOUR ACCESS TOKEN] -
I have tried the following from credentials for a Service account that I set up
Service account - Key - 3......................e76
Unique ID - 1............39
for the API KEY and the ACCESS TOKEN and get a 403 error back
I also have a Oauth credentials -
Client ID - 2.....113-95.......cpqrarqb.....qnrpc.apps.googleusercontent.com
Client Secret - L......lq
PATH
https://firestore.googleapis.com/v1/projects/{project_id}/databases/{database_id}/collectionGroups/{collectionId}/fields/{field_id}
Which didn't work either...
Again, I am trying to access and read and write data to my Firestore database using CURL - as a proxy for what will be my REST API's. Any help and assistance much appreciated.
From the curl commands you have pasted I understand that you want to export your firestore collections to a Cloud Storage bucket. Furthermore I understand you obtained the curl commands from the api explorer of the exports method.
To provide an api key value to [YOUR_API_KEY], you first need to create an api key in your GCP project; here is the process:
Go to the credentials section.
Click on the option at the top called 'Create Credentials'.
Select API key.
Copy and keep safe the value thrown by the Cloud Console (this is your api key).
If you want to know more about API keys, you can visit this.
To provide an oauth token value, you can do the following:
You can open Cloud Shell.
Run command gcloud auth application-default print-access-token.
Copy and keep safe the value thrown by Cloud Shell (this is your oauth token).
Please note that there are several ways to create an oauth token but the one I specified is the fastest one. You may also use the oauth playground to generate your token; keep in mind that the token is valid for 60 minutes.
As per the database id I have used (default) and here I include my curl statement:
curl --request POST \
'https://firestore.googleapis.com/v1/projects/[PROJECT_ID]/databases/(default):exportDocuments?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"collectionIds":["users"],"outputUriPrefix":"gs://[BUCKET_PATH]"}' \
--compressed
Nowadays I am working on Linkedin AdSupplyForecast api to follow at the below reference,
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/advertising-targeting/ad-supply-forecasts#find-supply-by-criteriav2
However the sample code does not work also I can not find any extra description about criteriaV2.
Standart Api sample at the below and response is '{"message":"Invalid HTTP Request","status":404}'
curl -H "Authorization:Bearer XX" -H "Content-Type:application/json" "https://api.linkedin.com/v2/adSupplyForecasts?q=criteriaV2&account=urn%3Ali%3AsponsoredAccount%3A518121035&timeRange=(start: 1587639976000,end: 1589540776000)&campaignType=SPONSORED_UPDATES&competingBid=(bidType:CPM,bidPrice:(currencyCode:USD,amount:10))&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3AcountryGroup%3ANA))))),exclude:(or:(urn%3Ali%3AadTargetingFacet%3AstaffCountRanges:List(urn%3Ali%3AstaffCountRange%3A%2810001%2C2147483647%29))))"
I modified it and like as at the below but it send server error '{"message":"Internal Server Error","status":500}', would you share with me a correct sample of it ?
curl --location --request GET 'https://api.linkedin.com/v2/adSupplyForecasts?q=criteriaV2&account=urn:li:sponsoredAccount:518121035&timeRange.start=1587639976000&timeRange.end=1589540776000&campaignType=SPONSORED_UPDATES&targetingCriteria.include=and:List%28%28or:%28{encoded%20urn:li:adTargetingFacet:locations}:List%28{encoded%20urn:li:countryGroup:NA}%29%29%29%29&targetingCriteria.exclude=or:%28{encoded%20urn:li:adTargetingFacet:staffCountRanges}:List%28{encoded%20urn:li:staffCountRange:%2810001,2147483647%29}%29%29' \ --header 'Authorization: XXX'
I am developing an app with swift and try integrating push notifications.
Firebase send push notifications via curl command works, but not from firebase console.
I followed every step from different tutorials, used the AuthKey, the bundle ID is correct and i do not receive any errors and the status of the push notification is "done/finished".
Here is the curl command i am using
curl --header "Content-Type: application/json" \
--header "Authorization: key="My Server Key"
https://fcm.googleapis.com/fcm/send \
-d '{"notification": {"body": "Hellof!", "sound": "default"},
"priority": "high",
"to": "FMC push token"}'
I hope someone has a solution for that problem or similar experience.
I too got it working in curl using a similar JSON structure as given by you. But in some cases it was resulting in null values for the body and title (I used the title field also)
It became better when I used "data" instead of "notification" in the JSON
Try changing the JSON as shown below. I have not tried it out myself in the exact context that you describe (Firebase console) but when I did that using CURL I found that both body and title are correctly being displayed in the notification
curl --header "Content-Type: application/json" \
--header "Authorization: key="My Server Key"
https://fcm.googleapis.com/fcm/send \
-d '{"data": {"title": "The Title","body": "Hellof!", "sound": "default"},
"priority": "high",
"to": "FMC push token"}'