I keep on getting a 400 response on this API request. With same appID and header I can make a succesful get request to retrieve all users. So it’s def not authentication. Email also certainly exists in my database.
Any ideas?
This is python:
import requests
import json
appID = xyz
head = {
'Authorization': 'Bearer xyz',
'Content-Type': 'application/json'
}
url = 'https://api.adalo.com/notifications'
body = {
"appId": appID,
"audience": {"email" : "abc@gmail.com"},
"notification": {
"titleText": "Hello There",
"bodyText": "This is just a test..."
}
}
notify = requests.post(url, headers=head, data=body)
print(notify)
head is a variable as is appID, just not initialized for privacy reasons here ;). With same header I can succesfully perform a GET request, so the header shouldn’t be the issue (neither should the appID, because in my get methodology I also use a variable).
I’ve just tested Push notifications via API on one of my test apps - it works for me perfectly. I did it via Postman.
So as I think the problem is somewhere within your app.
By the way, did you make any native build of your app for iOS or Android? Push notifications won’t work if there were no builds before (see help doc, “In order for these API requests to succeed, you must first have at least one native build of your app. The build can be for either iOS or Android, and you do not need to have published your app to the app stores.”)
If you have successfully completed at least one build of your app, and push notifications API isn’t working for you, then it would be a good idea to submit a support ticket:
Also, 400 isn’t just a response number alone. Usually you get some text along with 400 response, which may help to indicate what’s the problem.