I'm creating a session along with a name and Service URL followed by performing a post request with passing a file(XML file in the form of Dictionary) as a parameter.
But response code is '500 'instead of '200' (i.e. success).
Library Used:
Library RequestsLibrary
Snapshot of code used in Testcases section:
create session session http://myservice.com/method #(Just an example)
${response}= Post Request session /post files=${files}
Error: Not getting any error. Moreover Line of Code which has "Post
Request" is passing. But the status of response code is "500"
(Supposed to be "200").
A 500 response code means your request worked, but that the server threw an error. You need to check the server logs for more information.
Related
I am testing a controlling algorithm. I am using windows-hosting/plesk and c#.
I am having a problem like this:
My hosting account is called myhosting.com.
My sites in this account,
myhosting.com , files in httpdocs folder
second.com , files in second.com folder
controller.com , files in controller.com folder
Normal running process:
A page on second.com sends an HTTP-POST request to a page on controller.com,
for to get a string.
Before controller.com responds to the POST request, sends an HTTP-GET request
to an another page on second.com, for to get the control string.
The page on controller.com, because the string it receives with GET is correct
it responds positively to the POST request in the first step.
Incorrect operation (performing normal operation from myhosting.com):
A page on myhosting.com sends an HTTP-POST request to a page on controller.com,
for to get a string.
Before controller.com responds to the POST request, sends an HTTP-GET request
to an another page on myhosting.com, for to get the control string.
According to the log records, myhosting.com responded to the GET request
although, the page on controller.com has not yet evaluated the GET's response,
it answers the POST request in the first step with the HTTP 500 error. The error
cannot catch with try/catch.
Where does the error come from? Access permissions? Verb settings? It was working
initially. I deleted the index.aspx from the default doc list in the myhosting.com
and unwittingly did another action, then the error started to occur.
Thanks in advance for the answers.
Solved with Failed Request Tracing. The reply to the post message contains no error details. With this method, error details can be obtained.
I am trying to connect my bot to an azure function with a db. I entered the azure function URL as the webhook, it recieves the request as a POST http message.
I tried to respond with the following test message (and many more simpler ones):
{
"fulfillmentText":"fulfillmentText",
"fulfillmentMessages": [{"simpleResponse":{"textToSpeech":"text","ssml":"ssml","displayText":"text"}}]
}
and got a response:
Webhook call failed. Error: Failed to parse webhook JSON response:
Expect message object but got:
"笀∀昀甀氀昀椀氀氀洀攀渀琀吀攀砀琀∀㨀∀昀甀氀昀椀氀氀洀攀渀琀吀攀砀琀∀Ⰰ∀昀甀氀昀椀氀氀洀攀渀琀䴀攀猀猀愀最攀猀∀㨀嬀笀∀猀椀洀瀀氀攀刀攀猀瀀漀渀猀攀∀㨀笀∀琀攀砀琀吀漀匀瀀攀攀挀栀∀㨀∀琀攀砀琀∀Ⰰ∀猀猀洀氀∀㨀∀猀猀洀氀∀Ⰰ∀搀椀猀瀀氀愀礀吀攀砀琀∀㨀∀琀攀砀琀∀紀紀崀紀".
Everytime I enter a query in dialogflow I can check the diagnostic info and I see the response clearly in the "Fufillment Response" tab but then there's the above error in the "Response Status" tab.
Help would me much appreciated.
It looks like the content type of the HTTP response may be unclear. Make sure the HTTP response sets the content-type header explicitly to "application/json" or possibly event "application/json; charset=utf-8".
The problem has something to do with the Azure functions URL. For me a workaround was to write the function in visual studio, deploy to localhost, and use ngrok as a tunnel for dialogflow to call the webhook, rather than using the Azure Functions URL.
I would like this exception to be caused:
// ErrBodyNotAllowed is returned by ResponseWriter.Write calls
// when the HTTP method or response code does not permit a
// body.
ErrBodyNotAllowed = errors.New("http: request method or response status code does not allow body")
When I send HEAD request with body using fiddler I get 400/504 error codes, but I don't see any error log in my application.
I assume you're talking about a go server that you control. You should see this error returned when you call writer.Write() on a HEAD request. You need to handle it in your application by checking for that error. Find where you are calling Write, and check for the error, then display it to the user. You probably need to replace:
writer.Write(data)
with something like:
_,err := writer.Write(data)
I am using GSM module (M95 Quectel). As per given example of Send HTTP GET Request in Quectel http command manual, I am sending the command but in the end I failed to get a response from the server side. Its show the following error when sending:
send AT+QHTTPGET
+CME ERROR 3827
How can I get the correct response and read the data?
The QHTTPGET command should be sent with the to_read_time variable. for example:
AT+QHTTPGET=60 please check if this is what you are doing.
In addition, you can check the URL you are trying to perform the GET request to in chrome, by entering it and view the response to check server validity.
Also, you can try checking if you mannage to perform a GET request to a test server such as in here:
HTTP Test server that accepts GET/Post calls
Scenario:
A POST request is sent to process an order that will result in data retrieval from an external datasource.
There are three possible results:
The datasource returned data for the request
No data was available for the request (this is viewed as an error)
The datasource couldn't be accessed (may be down for maintenance)
An obvious response for 1 is 200: OK or 201: Created (an entity is created from this request).
What status codes would be appropriate for 2 and 3?
Status codes I have considered:
503: Service Unavailable when datasource is down
500: Internal Server Error when datasource is down
502: Bad Gateway when "no data available"
404: Not Found when "no data available"
403: Forbidden when "no data available"
412: Precondition Failed when "no data available"
2) Looking back at this, I agree it should probably be either a 204 No Content or maybe a 200 with a body indicating no records or resources could be found depending on the structure returned.
404's are generally used when the resource URI doesn't exist or a resource in the URI is not found in the case of a restful service.
3) 503 Service Unavailable
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.
Note: The existence of the 503 status code does not imply that a
server must use it when becoming overloaded. Some servers may wish
to simply refuse the connection.
3) I agree with 503 for this
2) Frankly I think a good argument could be made for using 204 in case 2 You can include metainfo in the header to indicate specifically what 'went wrong'. It really depends on how much you consider this case to be 'an error' at the API level.
If the API itself is functioning as intended, and the request was to a valid endpoint, by an authenticated and authorized user and did not cause the server to malfunction, then very few of the 400 or 500 series errors would really seem to apply.
for example, 404 usually means the URI you called does not exist, if it does exist, then using that code is misleading at least IMHO
**10.2.5 204 No Content**
The server has fulfilled the request but does not need to return an
entity-body, and might want to return updated metainformation. The
response MAY include new or updated metainformation in the form of
entity-headers, which if present SHOULD be associated with the
requested variant.
If the client is a user agent, it SHOULD NOT change its document view
from that which caused the request to be sent. This response is
primarily intended to allow input for actions to take place without
causing a change to the user agent's active document view, although
any new or updated metainformation SHOULD be applied to the document
currently in the user agent's active view.
The 204 response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields.
HTTP 404 - With your own error message like "No data found".
Twitter uses 404.
Reference: https://developer.twitter.com/en/docs/basics/response-codes.html
The datasource returned data for the request
200: OK/201: CREATED
Because everything is working as expected
No data was available for the request (this is viewed as an error)
400: BAD REQUEST
The request was invalid or cannot be otherwise served. An accompanying error message will explain further inside the body.like:
HTTP 400
{
response: null,
code: "USER_101", //should be used customized error codes here
error: "User details not found"
}
The datasource couldn't be accessed (may be down for maintenance)
404: Resource/URI NOT FOUND
The URI requested or resource is invalid
Like: https://www.lipsum.com/list-page
**/list-page** is not defined/found
Find here most frequently used status codes:
200 – OK
Everything is working, The resource has been fetched and is transmitted in the message body.
201 – CREATED
A new resource has been created
204 – NO CONTENT
The resource was successfully deleted, no response body
304 – NOT MODIFIED
This is used for caching purposes. It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.
400 – BAD REQUEST
The request was invalid or cannot be served. The exact error should be explained in the error payload.
401 – UNAUTHORIZED
The request requires user authentication.
403 – FORBIDDEN
The server understood the request but is refusing it or the access is not allowed.
404 – NOT FOUND
There is no resource behind the URI.
500 – INTERNAL SERVER ERROR API
If an error occurs in the global catch blog, the stack trace should be logged and not returned as a response.
In my opinion the best way to handle this is with a 200 no result object.
Why?
You have a response that you can do something with without a lot of trouble. I searched, everything worked correctly but there wasn't anything in the database to give a result. Therefore, result = null and a message explaining as much. If something found this in the network calls it is not a security risk.
If you are concerned with a security risk then a 204 is probably the best approach.
res.status(200).send({
result: null,
message: 'No result'
});