What does "400 Bad request" mean in HTTP2 APNs response? - apple-push-notifications

By using the new HTTP2 APNs Notification API, there is a response code 400 Bad request returns. What does this mean? Invalid token? Invalid payload? Or anything else?
Thanks.

You can check the payload, it will have reason along with 400 error code.
PayLoad = {"reason":"BadDeviceToken"}
In my case we used debug build to point to production APNS and APNS rejected with 400

Related

Notification payload sent to APNS through HTTP/2 Request with status code 200

I'm trying to send 1000 notification payload to APNS server for the same device token. When my program sent out the notification payload to APNS, through http/2 and getting the response 200 for all my requests. And it confirms that the payload is sent to APNS server. However, the device cannot receive any notification, did i missed anything!
Thanks in advance...

403 error response from IIS on almost alternate request while load testing api

I have a web api which is deployed on IIS.
Api's are going through load test using load runner and almost on all alternative api call, getting 403 error response code, struggling to identify the issue, call is not going to the API, its returned back from IIS
I am doing bearer token authorization, somehow token which were incoming with each request were not valid, that is why the issue was occurring, to overcome this we have increased the lifetime of token to 1 hour and request load test team to generate the token once and send that token only with each request so that we can now see the proper execution time for each end point.
403 error indicates that access to the requested URL by the client is Forbidden for some reason. you need to provide detailed error message snapshot and what is the sub status code. and check that you assign this permission to the site folder:1) IIS_IUSRS,2)NETWORK SERVICE,3)IUSR

REST API Create Session Error [tokbox] or [opentok]

Getting an issue when trying to call opentok/session/create api.
When calling the api through code i keep getting an error saying the connection has been closed. So I decided to try through postman and the error i'm getting back is a 500 internal server error and a message
{
"message": "Internal server error, working hard to fix it, sorry",
"code": -1
}
As far as I can see I have everything set correctly.
Headers, Body ]
I don't think this is a JWT issue as according to the documentation that would be a 403. https://tokbox.com/developer/rest/#session_id_production
Anyone experienced this or a similar issue before
The issue ended up being the content Content-Type header I had to set
Content-Type: application/x-www-form-urlencoded
Credit to #adrice727's comment for suggesting there might be an issue with the Content-Type header.

HTTP response code to indicate a bug in the client

I am developing both client and server. During development, I would the server to detect when the client appears to be buggy (send invalid data, omits mandatory parameter, etc, etc).
Is there a standard HTTP response code to indicate this? Or several, depending on the nature of the bug?
Or should I just use my own response code?
e.g 2001 I'm afraid I can't do that, Dave?
or 666 Mwuuuuuuhahhahahahahahahaha
HTTP 400 "Bad Request"
https://www.rfc-editor.org/rfc/rfc7231#section-6.5.1
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).

AFNetworking says "cannot parse response"

I am sending a request to server, which is handling the request and responsding. However on my app I am receiving:
Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo=0x167668d0
{NSErrorFailingURLStringKey=https://***, _kCFStreamErrorCodeKey=-1,
NSErrorFailingURLKey=https://***/, NSLocalizedDescription=cannot
parse response, _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x16731990 "cannot parse
response"
Accept field in http request is adequate.
I cannot even see what messege is arriving, because NSHTTPURLResponse object is null.
What can be an issue and in what way I can see what message is coming not using things like wireshark.
Thank You!
I got the same problem, and the reason is that the API require GET http method, and I need pass a parameter, I send it by the following code:
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
When I execute the request with GET method, it will report the error.
My solution is when the API need GET method, the parameter should add on the URL, such as http://apiserver/api?paramName=paramValue, when the API method is POST, then use the code above, set the HTTPBody for the request object.
If iOS cannot parse response, the problem must be in improper format http response from server, even if You are said, that everything is 100% correct, bacause other services communicate with it.
In my case an Android app communicated successfully, because network framework used there was not so restrictive and even if the content-length of http response does not fit the actual length of data, it could read this message, unlike ios.
Use tcpdump to check http communication!
I got the same issue when I tried to call a web method using http GET method instead of http POST. The web service method was expecting POST request not GET. Hope this information will help some one.
If you are using (iOS8 has a problem with this but works in iOS7)
NSData *dataToSend = [jsonData dataUsingEncoding:NSUTF16BigEndianStringEncoding]
to send to the server, please make it as per below:
NSData *dataToSend = [jsonData dataUsingEncoding:NSUTF8StringEncoding]
I was seeing this error because a framework I was using was trying to send URL parameters in a GET request inside a JSON encoded body (instead of as URL-encoded parameters in the URL string as it should have been). That was causing the server send back an "invalid parameters message" which the client couldn't handle and instead aborted mid-request. Switching from body parameters to URL-encoded parameters for GET requests fixed the problem.
First I would ensure you are sending the correct parameters both in the body and the headers. I was receiving this error and after moving one of the parameters from the body into the header I received the correct response.
If there is any documentation for the api make sure you follow it properly.

Resources