My Advanced Rest Client was working perfectly and sending message. Maybe it send 10 messages, but after that it is showing this message. Please tell me whats wrong with it.
Here is the picture of the error
Here is my message body
{
"to":"/topics/NEWS",
"data":
{
"title":"Eid Notification",
"img_url":"http://www.pakworkers.com/wp-content/uploads/2017/06/Eid-ul-Fitr-Holidays-Announced-by-Interior-Ministry-of-Pakistan-26-28-June-2017.jpg"
}
}
response is 200 OK so no issues while getting response.
Issue is to change message Id in json from number to string in backend rest application.
Related
I'm working with WebSockets in Gatling and have a slight issue in that I get multiple responses with the same message and different values, but the original message is sent only once. The subsequent web socket responses are triggered by a graphql post.
Obviously .exec(ws("Web Socket Request").await(5) doesn't work so Im wondering how I would await and check the subsequent message?
You can see the requests in dev console here. Message with "id": "11" is sent and message with "id": "11" is received, then another one ("id": "11") is received after the graphql call.
So my code currently looks like this:
.exec(graphQlRequests.onlineStatus(false))
.exec(graphQlRequests.chatRooms())
.exec(
ws("Video Watch").sendText(subscriptionQueries.videoWatch()).await(5)
.on(ws.checkTextMessage("Video Watch").check(jsonPath("\$..choices[0].id")
.saveAs("choice")))
)
.exec(ws("New Messages").sendText(subscriptionQueries.newMessages()))
.pause(1)
.exec(graphQlRequests.startVideo())
.exec(graphQlRequests.chatRoom())
.exec(graphQlRequests.onlineStatus(false))
.exec(graphQlRequests.chatRoom())
.exec(graphQlRequests.onlineStatus(true))
.pause(9)
.exec(graphQlRequests.onlineStatus(true))
.pause(3)
.exec(graphQlRequests.videoChoice())
// Capture the second WebSocket message here.....
.exec(graphQlRequests.onlineStatus(true))
.pause(15)
.exec(graphQlRequests.onlineStatus(false))
What is the best way to capture the second request? Do I need to open up a separate SSE connection?
That's a similar issue as https://github.com/gatling/gatling/issues/3809.
In short, the expected WebSocket inbound message might have already been received between your HTTP request and your WebSocket await, so the latter misses it.
You're welcome to help with specifying a proper solution on our bug tracker (but no "upvote", "me too" or "+1" please, it doesn't help in any way and doesn't make things happen faster).
I have seen a lot applications using REST API returning a status code inside theirs response bodies, although the HTTP response returns the status code just fine. Is there any reason to put the status code also in the body of the response?
Some APIs return a 200 for all requests, even erroneous ones, and put a status code in the response body. This status code might mimic HTTP status codes, but doesn't have to. One could start numbering your response statuses from 1 for all anyone cares.
Other APIs return appropriate HTTP status codes, and indeed, put the same status code in the response. That's just a waste of bandwidth and brain cells, and a cause for lots of head scratching. It's unnecessary. Except...
It might be useful for some kinds of client libraries. When a client application uses a library that abstracts away all the HTTP stuff, it can just return an object to the programmer that contains all information about the response.
Something like:
{
"status": 200,
"data": {
"foo" : "bar"
}
}
And:
{
"status": 401,
"data": null,
"message": "You are not authorized."
}
This way the library author can chuck the HTTP status code into the object's status property, and the caller doesn't have to deal with exception handling.
But then still there's no reason for the API to respond with it both in HTTP status code and response.
Is there any reason to put the status code also in the body of the response?
Yes, in the sense that the status-line is HTTP metadata, describing the semantics of the response message. Like other HTTP metadata, it's not really designed for use by the end client.
Consider the web experience - the browser gets to see the HTTP response message, and can act on it. But what information do you want to share with the user? In cases where you wanted the user to be aware of the HTTP status code, you would include it in the HTML representation also.
Problem Details for HTTP APIs includes an optional status field in its schema to surface that information for the client.
I am trying to subscribe my app instance for a topic as described here. Creating a relation mapping for one app instance works ok.
Problem appears when I am trying to create relation mapping for multiple app instances. GCM returns HTTP status 400 with error "Topic name format is invalid" regardless the fact that I match regular expression for topic name described here.
Even the example POST request from documentation is not working for me again with same error message and I can not find any topic name for which request would pass successfully.
Request
https://iid.googleapis.com/iid/v1:batchAdd
Content-Type:application/json
Authorization:key=API_KEY
{
"to": "movies",
"registration_tokens": ["nKctODamlM4:CKrh_PC8kIb7O...", "1uoasi24:9jsjwuw...", "798aywu:cba420..."],
}
Response
HTTP 400 Bad Request
{
"error": "Topic name format is invalid"
}
Same situation happens for batchRemove request.
The GCM documentation insists you use the prefix /topics/ before your own choice of topic name.
So in your case, your apps need to specify the string /topics/movies during the client-side registration process, and the first line of your JSON in the server's POST request you have detailed above needs to be "to": "/topics/movies",
Since 2 days I've been exploring the Telegram bot API, which is pretty neat. But there is one thing I can't figure out.
When you don't use the webHook but the /getUpdates call, you can tell the API via the offset parameter which message where processed by the server.
But how do you do this with the webHook in place? I keep getting the same message as an update. Which results in the server spamming the user with the same message.
The solution I came up with is as follows:
Receive an update from the webhook
Save the update_id
Reply to the user /sendMessage
disable the webHook /setWebhook?url=
Set the offset /getUpdates?offset={update_id+1}
Reinstate the webHook /setWebhook?url=https://mywebhook.domain.com
There must be a better way right? Anyone?
Ok, problem solved. It appeared that just a 200 (OK) wasn't enough (the body of my response was null. I've added a body to the response {}, and know it works fine.
You must say to telegram that you get updates successfully with this:
- 200 response code
&
- empty json like this {}
use This on webHook to get data from telegram servers:
// get the raw POST data
$rawData = file_get_contents("php://input");
// this returns null if not valid json
$jsonData = json_decode($rawData);
What HTTP status code are you returning on the page handling your webhook? It is possible that Telegram is attempting to retry your webhook endpoint because it's not receiving a status 200 (OK) from you.
my head is spinning cause of the following issue. I'm accessing my webservice (running on my localhost:4434) with AngularJS and if something goes wrong, the webservice sends a response 400 containing a json body which contains a message that tells you what exactly went wrong.
Problem is I cannot access the message on the client? It is almost as if it never reaches the client?? (This isn't the case, I've confirmed that it reaches the client already) This is the angular code that I use on the client site.
$scope.create = function() {
$http.post('http://localhost:4434/scrapetastic/foo', $scope.bar).
success(function(data, status, headers, config) {
console.log("Call to log: "+status);
console.log("Call to log: "+data);
}).
error(function(data, status) {
console.log("Error|Data:"+data);
console.log(status);
});
}
If I submit malformed data a corresponding error response is generated but as I said ... somehow I cannot access the message that is contained in the response body. This is what I get:
I've tried all sorts of things but am seriously stuck now...perhaps someone has an idea on how to access the payload of the response or at least what to do next? I'm also dealing with CORS perhaps it has something to do with that.
Thanks!
I'm going to take a wild guess here and say that your problem is an XSS issue.
Not only do you not have the data variable, but as far as I can tell from your screenshot, status == 0.
Your screenshot also says Origin: http://localhost, which makes this request considered XSS (since the port is different). That would explain why status is 0.
Edit: You can use jsonp to get around the issue.