I am trying to add multiple host header for post http request on postman , but I am getting error like Error: hostHeader.startsWith is not a function .
If I pass single header it is working , but if I pass one more header it is throwing the error could not send the request with the above message.
Is there any configuration I need to have to allow multiple host headers
Related
I have MVC project that includes an Action for downloading file.
When settings the response BufferOutput to false the server throws exception
cannot append header after HTTP headers have been sent.
This is because when Action executed there is an Action Attribute that adds headers to the response.
Is it possible to achieve the goal to download file without forcing the client to wait till all data is completed in this way?
Thank you
I created an AWS API-gateway for an HTTP method PUT. When I do a test in API-gateway, that works fine, but when I call it from a REST client, I get 404 bad-request and missing authentication token errors. I didn't set any authorization to true or a required API key to true.
I passed these query parameters to a REST client:
auth_id : 8798iuyiu123123
time_stamp :1231231
test_json : [{"id"=>"1","value"=>"mount"},{"id"=>"2","value"=>"chart"}]
HEADER
content-type : application/json
When I change the test_json value to %5B%7B%22id%22:%221%22,%22value%22:%22test%22%7D,%7B%22id%22:%222%22,%22value%22:%2213+%D8%B4%D8%A7%D8%B1%D8%, then I get the response.
i am new to react, calling from react
Request.put('https://api-gateway.sqwdwed123.com/eretw/update-chart')
.set('Content-Type', 'application/json')
.query({ auth_id: localStorage.auth_id})
.query({ time_stamp:this.props.time_stamp})
.query({ test_json:JSON.stringify(newadd)})
should i pass this test_json through body?
Am I doing anything wrong?
This is usually related to requesting a URL that doesn't exist. Please make sure you're using the correct HTTP method and resource path to a valid resource (the sample invoke URL does not include any resource path). If this still doesn't work. Make sure you actually deployed your API.
The HTTP Response of Bad Request is because you have the Query Parameter that are not URL Encoded. There are 2 things that you can do now:
Pass the test_json as Query Param but making sure that they are URL Encoded. This will put a restriction on the size of the string and hence Not Recommended.
Pass the test_json as Request Body. (Recommended)
I am trying to call a batch request from angularjs using a service(angular-http-batch.js) to an ODataV4 Web Api endpoint.But i am getting the error
"The 'Content-Type' header value 'application/http; msgtype=request' is invalid. When this is the start of the change set, the value must be 'multipart/mixed'; otherwise it must be 'application/http'."
Is i missed out any configuration in odata ?.
I have a Grails controller that receives a DefaultMultipartHttpServletRequest like so:
def myController() {
DefaultMultipartHttpServletRequest proxyRequest = (DefaultMultipartHttpServletRequest) request
}
This controller acts as a proxy by taking pieces of this request and then resends the request to another destination.
For non-multipart requests, this worked fine, I did something like:
IProxyService service = (IProxyService) clientFactory.create()
Response response = service.doPOST(proxyRequest.getRequestBody())
Where proxyRequest.getRequestBody() contains a JSON block containing the request payload.
However, I do not know how to get this to work with multipart request payload, since the request body is no longer a simple block of JSON, but something like the following (taken from Chrome devtools):
How can I can pass this request payload through using my proxy service above, where doPost takes a String?
Have you tried
def parameterValue = request.getParameter("parameterName")
to get the parameter value?
If you see the method signatures for DefaultMultipartHttpServletRequest you will see there are methods for getting the files and other parameters separately because the request body is getting used to both upload the file and to pass in other parameters.
I am trying to create a PUT request using Fiddler but I am constantly receiving an error as follows.
PUT Request
https://127.0.0.1/odata/ControllerName('param')
Request Header
Accept: application/json;odata=minimalmetadata
Host: 127.0.0.1
Authorization: ApiKey uniqueKey
Content-Type: application/json;odata=minimalmetadata
Accept-Charset: UTF-8
RequestBody
{"Name":"param"}
When I am trying to PUT, it returns me status code 400. When I double click error in fiddler and view JSON tab, it gives me following error.
odata.error
innererror
message=actionParameters : The last segment of the request URI 'ControllerName('param')' was not recognized as an OData action.
Where I am going wrong, with URI format or request body?
According to OData protocol,
the value within the parenthesis following the entity set(corresponds to a controller) must be a key, for example:
~/odata/Products(1) if the key is of int type,
~/odata/Products('1') if the key is of string type.
So please make sure the key is of string type in your case, and try to
GET https://127.0.0.1/odata/ControllerName('param')
to see whether the response is as expected.