The request's Authentication (Server-) Key contained an invalid or malformed FCM-Token (a.k.a. IID-Token). Error 401 - firebase-cloud-messaging

try to POST FCM from Postman, but got error message
"The request's Authentication (Server-) Key contained an invalid or malformed FCM-Token (a.k.a. IID-Token).
Error 401"
note: copy auth key from Project credentials-Server key
url : https://fcm.googleapis.com/fcm/send
header
Content-Type : application/json
Authorization : key=AAAAQJ50ukk:Gf9m5PCwpwb1EG .....aovqy
Body :
{
"to": "",
"data":
{
"title":"Test"
"message":"Test Message"
}
}

Related

Can i send raw like form-data in postman?

Can i send raw like form-data in postman? Because i think the server accepts only multipart data which we send via form-data but i need to send the same data via raw.
DATA -
{
"uploadRequest": {
"fileType": "OTHER_EVIDENCE",
"description": "other"
},
"uploadedFile": "cypress/fixtures/evidence.jpeg"
}
ERROR -
{
"httpStatusCode": 500,
"errors": [
{
"code": "1001",
"description": "A service exception has occurred",
"details": "Failed to parse multipart servlet request; nested exception is javax.servlet.ServletException: org.apache.tomcat.util.http.fileupload.impl.InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/json"
}
]
}
but if i send this data via form-data it works fine
SUCCESS IMAGE

Get error sending POST request to openweathermap via postman

I'm starting to learn the REST API. I use POSTMAN for this and openweathermap.org.
I am sending the name of the city in the body. The body has json format:
{
"cityName" : "Poltava,UA"
}
Response from the server:
{
"cod": "400",
"message": "Nothing to geocode"
}
Please tell me where I am going wrong? I changed the name of the key to "q", "city" and wrote simply "Poltava" and always I get the same error.
API docs: https://openweathermap.org/current
Headers of my request is:
Headers

mail.send is not accepting HTML/ CSS code

I have copied the (HTML) source code from a received email just to have the template/format of that email, and this is the error message that I am receiveing when running the API:
Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 400
HTTP Response Content: {
"error": {
"code": "BadRequest",
"message": "Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.",
"innerError": {
"date": "2020-12-02T17:01:05",
"request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d",
"client-request-id": "3ab50fc1-0c13-4536-96db-bf6b9b7a736d"
}
}
}
I have tested basic commands using HTML such as making text bold and line breaks which work, but anything more complex and I will receive an error.
Update**
Thank you for your response guys, the call that I'm using looks like this:
{
"message": {
"subject": "[Subject]",
"body": {
"contentType": "HTML",
"content": "[Email Body Content]"
},
"toRecipients": [
{
"emailAddress": {
"address": "[Email Address]"
}
}
],
"internetMessageHeaders":[
{
"name":"x-custom-header-group-name",
"value":"Nevada"
},
{
"name":"x-custom-header-group-id",
"value":"NV001"
}
]
}
}
**Another update ** Upon changing the content type to text/html is recieved this error:
Internal : Unexpected error Error during Web API HTTP Request
HTTP Status Code: 415
HTTP Response Content: {"error":{"code":"RequestBodyRead","message":"A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'Microsoft.OData.ODataMediaType, Microsoft.OData.ODataMediaTyp...' matches the content type 'text/plain; charset=utf-8'."}}
note i also have tried text/plain as the content type.
Thank you
Ok, I tried the above payload (just updated the email address) and tested with Microsoft Graph Explorer. It works for me :)
Here's the payload:
{"message":{"subject":"[Subject]","body":{"contentType":"HTML","content":"[Email Body Content]"},"toRecipients":[{"emailAddress":{"address":"test#domain.onmicrosoft.com"}}],"internetMessageHeaders":[{"name":"x-custom-header-group-name","value":"Nevada"},{"name":"x-custom-header-group-id","value":"NV001"}]}}
Here's the snapshot:

how to fix 'InvalidRegistration' FCM

I'm getting the InvalidRegistration error in response of my post request for sending push notification.
When I use the Firebase console to send push notification it works all fine.
so I copy the exact registration token I've used in console. I also get my api-key from my project-settings/cloud-messaging.
for sending the post request I've used postman.
I've sent my post request to https://fcm.googleapis.com/fcm/send
my postman header has this attributes:
key: Authorization value: key=<api-key-i-got-from-console>
key: Content-Type value: application/json
my body is:
{
"to" : "fDj8iG5ajZI:APA91bHfs_AjdxOc5Qn-1Plr_OfitrdCTchb4syhPGC0DhPMGiWggJ9mQ5W00ombqowlUSCUOfH_0N3KA-KF0VjQvj5mcMNUMUBgTblpsNzra60kwrbtH2ikfdBa8lenh__olBpGZD4O'",
"collapse_key" : "type_a",
"notification" : {
"body" : "plz work",
"title": "title"
},
}
I get this response from the Firebase
{
"multicast_id": 5801302802423881516,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "InvalidRegistration"
}
]
}
I did the same with fcm and django-push-notification and got the same result I have no clue what am I doing wrong since my token works with the console and I can send push notifications from the console.
it was my bad that I had an extra ' in the end of my token...

Getting the error "Mandatory grant_type form parameter missing" in postman

Here's the information entered on postman
URL - https://test.api.amadeus.com/v1/security/oauth2/token
Parameters:
grant_type - client_credentials
client_secret - {{My_API_Secret_key}}
client_id - {{My_API_key}}
Headers
Content Type : application/x-www-form-urlencoded
It returns this response :
{
"error": "invalid_request",
"error_description": "Mandatory grant_type form parameter missing",
"code": 38187,
"title": "Invalid parameters"
}
It's a post request. so you should pass these parameters under different type.
For example in python's requests library it would be inside your data:
requests.post("{}/v1/security/oauth2/token".format(url), data=YOURPARAMETERS, headers=YOURHEADERS )