When do a normal http request to a website, you would always be able to read the status code, 200, 400, 500 and so on.
Is this possible using UI4J?
Related
I am trying to use a REST Service as a Sink Dataset in my Dataflow, but it always fails with a Bad Request 400 Error.
Error
{"StatusCode":"DFExecutorUserError","Message":"Job failed due to reason: DF-REST_001 - Rest - Error response received from the server (url:https://my_url,request body: Some({"Name":"GREST"}), request method: POST, status code: 400), response body: Some({"error":{"name":"badRequest","message":"Request body has invalid format."}}))","Details":"com.microsoft.dataflow.Issues: DF-REST_001 - Rest - Error response received from the server (url:https://my_url,request body: Some({"Name":"GREST"}), request method: POST, status code: 400), response body: Some({"error":{"name":"badRequest","message":"Request body has invalid format."}}))\n\tat com.microsoft.dataflow.Utils$.failure(Utils.scala:75)\n\tat org.apache.spark.sql.execution.datasources.rest.RestClient.ensureSuccessResponse(RestClient.scala:430)\n\tat org.apache.spark.sql.execution.datasources.rest.RestClient.org$apache$spark$sql$execution$datasources$rest$RestClient$$executeRequest(RestClient.scala:415)\n\tat org.apache.spark.sql.execution.datasources.rest.RestClient.org$apache$spark$sql$execution$datasources$rest$RestClient$$executeSingleRowRequest(RestClient.scala:153)\n\tat org.apache.spark.sql.execution.datasources.rest.RestClient$$anonfun$savePartitionSingle$1$$anonfun$apply$mcV$sp$3.apply(RestClient.scala:106)\n\tat org.apache.spark.sql.execution.datasource"}
The status code 400 is a Bad Request error, and the server cannot process the request due to an error.
The possible reasons might be due to incorrect URL, malformed syntax, request body might have invalid JSON. Please check the URL and validate JSON data.
When you use copy activity and the method is POST, make sure that you send it in Additional headers section key -> "Content-Type" value -> "application-json"
I have confusion that, Im using 202 status code, when I receive a POST request from a client (A) and B is processing it , passing the output to another endpoint(C).
In this case I use 202 status code when B receives the request from A.( I have added the sample message flow.)
B is not sending any other response back to A. So is that right using 202 or it should be 200 ?
My understanding is, we use 200 for GET calls, and for POST we use 202 if processing is pending.
Here i have pending the processing and i forward that output to C. Not to A.
So here is my confusion to use 202 or 200 is right?
Edit
If it is a call back endpoint, (eg: in this picture B), would it be appropriate to have 200?
The main purpose of using 202 instead of 200 is for a server to communicate to a client: "From what I can tell, the request looks good. However, we haven't fully dealt with your request yet and we aren't 100% certain it's going to succeed".
So if someone does a request, the server immediately responds and then forwards the request elsewhere, a 202 makes sense to me. If the request fails at the C endpoint, A it will be too late for A to find out about this.
If you respond with 200, it tells a client that the request fully succeeded.
I try to use Postman to mock server functionality to mock an API call that will return status code 449. For some reason, the good response body is return, but the status code stays at 200.
I can change the example to return 404, 422, 451, and others, but as soon as I set 449 for the status code, it returns 200.
Is there a way to make the mock server return status code 449?
Edit:
I add a collection and environment that reproduce the problems
https://github.com/freddycoder/PostmanStatusCode
449 is not an official status code.
https://dynomapper.com/blog/254-the-6-types-of-http-status-codes-explained#:~:text=A%20449%20error%20appears%20when,order%20to%20fulfill%20a%20request.
The below site shows the officially assigned status codes. it seems like as of now unassigned ones are not supported in postman expect apache status code 509. Maybe mock servers use apache and 449, 450 etc are windows specific status codes.
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
You can test the specific usecase with the x-mock-response-code request header
On setting this header postman returns response only if the example of mock server has status code set as 449.
else you will get 404 mockRequestNotFoundError .
so in your test you can set pm.response.code = 449 if response code is 200;
To do this in pre reqeust set :
pm.response.code===200?pm.response.code=449:null
pm.response.code===449?pm.response.status="Retry With":null
console.log(pm.response.code,pm.response.status)
While defining RAML, in response body we will define response based on status codes like 200, 400, etc.
Why that seperate defination is required?
sample RAML
responses:
200:
body:
type: User
400:
body:
type: ErrorMessage
From controller i can send like
response = Request.CreateResponse(HttpStatusCode.Ambiguous, error);
This will create response as 300 status.
While hitting the api from Postman, i can able to get the response with status 300.
So Is it really needed to define the response for different status codes?
Is it really needed to define the response for different status codes?
RAML is a way of generating documentation and clients. Sure, you could document you're going to return a body of X and actually return a body of Y, but all that will cause is annoyed consumers.
So you could return the same response type for all response codes, or document when the response type varies per response code.
I think you are misunderstanding what RAML is.
RAML is documenting your API, it does not implement your API. So yes, you can have an implementation that is different from what your RAML specifies.
Is it really needed to define the response for different status codes?
No, in RAML the whole responses is optional. So you could just leave it out.
But the idea is that you specify RAML as close as your implementation as you can, so it is useful for you and other people.
While defining RAML, in response body we will define response based on
status codes like 200, 400, etc. Why that seperate defination is
required?
Different status codes usually mean different response data.
For example if you are getting a dog by id (/dogs/1) then if the dog is found you will return status code 200 and the body will contain data about the dog. e.g. { name: "foo", colour: "brown", ...}
On the other hand if there's no dog with id 1, then you will return status code 404 and in the body something like: { message: "a dog with id 1 was not found" }
since approximately half an hour i'm experiencing error 400 when trying to retrieve data from Parse via the javascript sdk.
I got the following errors :
POST https://api.parse.com/1/classes/LocalQuestion 400 (Bad Request)
b.Error {code: 159, message: "Failed to initialize mongo connection"}
This affect some of my apps, but not all of them. For those which have this problem the dashboard isn't accessible. (I receive an error message saying that something went wrong.