So I am receiving a Shopify webhook request to my asp.net application. I keep getting the following error.
'((Microsoft.AspNetCore.Http.DefaultHttpRequest)this.Request).Form' threw an exception of type 'System.InvalidOperationException'
If I put Request.Body it says item timed out. I am not sure how to read the stream that is getting sent to my action.
I can post any extra details you request I am not sure what to post here.
This we because I needed to read the incoming stream.
Related
I'm getting HTTP Status 405 – Method Not Allowed: "The method received in the request-line is known by the origin server but not supported by the target resource."
when I'm making the following REST API call
https://myantserver.example:5443/WebRTCAppEE/rest/v2/broadcasts/{id of my stream}/recording/true
Not sure what I'm doing wrong... Is there any setting I need to configure? The streams get saved just fine if i enable "Record Live Streams as MP4"
But I want to only record specific streams. If there was any way to "Record all livestreams where the stream ID includes a specific string" that would work as well.
Any suggestions appreciated, Thanks!
Solved it, the problem was that I was making a POST request instead of a PUT request
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 in reference to HttpServletResponse's sendError method:
void sendError(int sc,
java.lang.String msg)
throws java.io.IOException
... and the official documentation provided:
Sends an error response to the client using the specified status and
clears the buffer. The server defaults to creating the response to
look like an HTML-formatted server error page containing the specified
message, setting the content type to "text/html". The server will
preserve cookies and may clear or update any headers needed to serve
the error page as a valid response. If an error-page declaration has
been made for the web application corresponding to the status code
passed in, it will be served back in preference to the suggested msg
parameter and the msg parameter will be ignored.
If the response has
already been committed, this method throws an IllegalStateException.
After using this method, the response should be considered to be
committed and should not be written to.
Can anyone please explain what is meant by "clears the buffer" and "If the response has already been committed"?
what is meant by "clears the buffer"
The code will response.resetBuffer() which basically resets any written and unflushed data of response body.
and "If the response has already been committed"?
If the response headers are already sent to the client. This is a point of no return. The server cannot take back already sent data from the client and re-send a different response.
An example of the normal flow is as below:
user requests JSP
JSP writes some HTML to response body
some awkward code in midst of a JSP file throws an exception
server calls response.sendError(500) so that HTML of HTTP 500 error page will be written
user sees HTTP 500 error page
However, if between step 2 and 3 the response buffer is flushed (i.e. any so far written data gets actually sent from server to client), then the response is in a "committed" state. This cannot be resetted. The enduser basically ends up getting halfbaked HTML output representing the part until the point the exception has occurred.
That's also one of the reasons why doing business logic in a JSP file is a bad practice. See also a.o. How to avoid Java code in JSP files?
I've a two-way WCF receive port, where i've checked both:
1) Route failed messages
2) Suspend request message on failure
This configuration is needed to redirect failed messages to our "exception portal".
When a message is received and it fails validation in XMLReceive pipeline, the message is redirected to our "exception portal" as expected.
The problem is however that the consumer of the WCF service never get's a fault, so the Connection gets a timeout after a while, which is very confusing for the consumer.
Is there anyway to fix this problem? Am I missing something?
What's happening currently is that the message fails on the Receive pipeline, gets routed to your portal, but no response gets routed back. You have to make sure to send a message back. You could do that by:
creating an Orchestration that does the validation (instead of doing it on the pipeline), and making sure to send a response int he orchestration as well as routing failures to your portal
creating a custom component that validates the message (perhaps by calling the XML Validation pipeline in a try block and catching the exception without rethrowing it); on error it sends the message to your portal, and replaces pInMsg with something sensible to send back to the partner.
having your portal receive location be a request response port (perhaps, again, with an orchestration behind it), and route the response back to the WCF two way port. This way is more involved, and to be honest I'm not entirely sure what a working implementation would look like here, but it may be possible.
If it were up to me, I'd go for the Orchestration. You can certainly call the XML Validator pipeline from an orchestration, or you could use other validation logic in there (for example calling BRE).
I am using an SMS Gateway to make my application receive SMSs. For this, the SMS Gateway sends a request to one of the pages in my application with the message as a querystring parameter. eg. http://myapplication/SMSReceiver.aspx?Message=PaulaIsHome.
Now after my page gets invoked, I need to send an OK response to the SMS Gateway so that it doesn't keep retrying to send the same message to my application again and again. I cannot figure out how to send the OK response.
I am using ASP .Net and C#.
Thanks
You are invoking an ASPX page, so I am guessing that a bunch of HTML is being returned in the response. Use a generic handler instead (this is what they are for), and then you can easily control all of the output...
context.Response.ContentType = "text/plain"
context.Response.Write("OK")
context.Response.End()