HTTP Status Code suddenly changed to 202 Method Accepted - c#

I am using Rest web service that have 3 method (put , get , post) and im using c#.net.
When i publish in IIS 7,5, and im invoke the get method, what i got is method accepted 202.
It should be return status code 200 OK and the data what i want.
Is there anything wrong here ?
Method Accepted 202

That depends on what your API is set to respond with.
200 would be default but perhaps if it is expecting something else it is responding with a 202.
You have made a call but something is incorrect and processing may not have completed as expected.
Without knowing the API we cannot confirm what was wrong with your request or the processing of it.

Related

New Server Security Causing Issues To API Response

one of my old project/app was working fine for years, very recently client report that app does not working any longer due to API response issue.
it's just a get request to an API with some parameters..
till date (before issues occurs) it returns following response:
,,3,1669179307,0,
but recently it shows following response: (note nothing is changed in the source php/code files since project start)
<html><title>You are being redirected...</title>
<noscript>Javascript is required. Please enable javascript before you are allowed to see this page.</noscript>
<script>var s={},u,c,U,r,i,l=0,a,e=eval,w=String.fromCharCode,sucuri_cloudproxy_js='',S='bT0nP2RUNCcuc3Vic3RyKDMsIDEpICsgJycgKyAKJz9iVGYnLnN1YnN0cigzLCAxKSArICcnICsgCidIcExjJy5zdWJzdHIoMywgMSkgK1N0cmluZy5mcm9tQ2hhckNvZGUoNTYpICsgJ3FAYycuY2hhckF0KDIpKyAnJyArIAonNycgKyAgICcnICsgClN0cmluZy5mcm9tQ2hhckNvZGUoMHg2MykgKyAgJycgKycnKyIyc3VjdXIiLmNoYXJBdCgwKSsiYyIgKyAiNHNlYyIuc3Vic3RyKDAsMSkgKyAiZW0iLmNoYXJBdCgwKSArICAnJyArIAoiM2MiLmNoYXJBdCgwKSArICIiICtTdHJpbmcuZnJvbUNoYXJDb2RlKDk3KSArICJlIi5zbGljZSgwLDEpICsgICcnICsnZCcgKyAgJ0RiJy5zbGljZSgxLDIpKyAnJyArJycrJ3hJMScuY2hhckF0KDIpK1N0cmluZy5mcm9tQ2hhckNvZGUoMHgzMSkgKyAncTAwJy5jaGFyQXQoMikrU3RyaW5nLmZyb21DaGFyQ29kZSgweDYzKSArICIiICsnSHVIZScuc3Vic3Ry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;u<64;u++){s[A.charAt(u)]=u;}for(i=0;i<L;i++){c=s[S.charAt(i)];U=(U<<6)+c;l+=6;while(l>=8){((a=(U>>>(l-=8))&0xff)||(i<(L-2)))&&(r+=w(a));}}e(r);</script></html>
here is curl screenshot:
And here is the postman screenshot:
and when i check the URL in browser it shows the expected result, though when i check the devtool (network tab), it looks like page is loaded two times.. 1st one provide error (HTML/js) response (read marked) 2nd one provide the expected response (green marked), so, it looks like when it's called directly by curl/postman/c#... fails.. but as browser can do redirect it passed.
here is the browser screenshot:
i am sorry, i added several screenshot to give better idea what is happening.
and here is the URL in question:
https://simpleclienttracking.com/membershipmanager/remotelogvisit.php?locID=1&orgID=1&deptID=1&barcode=8346420
now my question, is how can i use the API code/file to get the direct response as i was getting earlier? do i need to pass any header? update/modify server htaccess file or what?
To test the error in deep, i have tried another URL from another hosting provider, in that case i am passing post request to an URL, and this server response slightly different thing, but looks like core is same, redirect!
here is the response from new/another server:
<script>document.cookie = "humans_21909=1"; document.location.reload(true)</script>
so, it's looks like hosting providers has applied some kind of security for direct URL access?
thanks in advance for any upcoming help
best regards

Http response erroring out when trying to read response from server

I'm having difficulties on retrieving data from my server. I activated CORS and set up my call properly(already tested it with postman). I'm sending the post request to my server, method is being hit but when returning and trying to read the response on the client side, the SDK fails.
This is the error I'm getting on the console.
Am I missing something here? do I have to use another plugin for the htttp calls in web environment?
Error information is incomplete, in which line do you get error?
I assume your uri and some other thing are ok.
change filtereDto to:
Map<String,dynamic> filterDto={
'date':'2020-02-07....',
'countryId':'1' // string number
}
And you dont need to :
json.encode(filterDto)
in post call, only filterDto is enough
... body: filterDto ...
I have found the issue. Cors was being enabled on my server side incorrectly. Order activating Cors is critical for configurations to be applied properly in a .Net core app.
This is how is done. First activate Cors and then MVC.
Hope it helps anyone who is struggling with the same thing.

Form Recogniser API call - error code 202-accepted

I used the labelled tool to train my model and got the model ID. Then I tried to make an API call (https://westeurope.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v2-preview/operations/AnalyzeWithCustomForm) and use this model ID to analyse form but got the error code 202. My resource (Form Recognizer cognitive service) is in West Europe. Any idea what might be wrong with my request? If I click on the Operation-location from the response, then I see the error code 401.
Is there anywhere I can find a source code for a blob triggered azure function so I can use the model ID I have created using the labelling tool? Thanks.
A 202 response is not an error code, instead it means that your first POST API call was successful. The next step would be to make a GET call (https://westeurope.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v2-preview/operations/GetAnalyzeFormResult) using the Operation-Location from your response and the same subscription key you used before.

XHR error on first mobile call is failing, subsequent calls are all successful

I have a vue js app that uses axios to open a new tab. Below is the code.
var win = window.open('')
win.document.body.innerHTML = Constants.LOADING_HTML
axios.get('/api/inventory/report?vehicleId=' + id, {
}).then(reporthtml => {
win.document.body.innerHTML = reporthtml.data
}).catch(error => {
win.document.body.innerHTML = error.response.data
win.document.title = 'Error'
})
The call works perfectly fine when testing on my computer. However, when testing on an iphone or ipad the first request that gets made throws an error. After closing the opened tab and then making the call again it works correctly, and all subsequent calls work as well.
When debugging through safari I see the following error in the console when that call fails. The first options call looks to return correctly. But the get fails with no response message or a response code. When looking at the api log, the call looks to succeed and return the appropriate data.
It looks like the catch is getting hit but not because of the api since error.response is empty. When examining just error, it says Network error.
Does anyone have any idea what may be causing this? I have also tried disabling the popup block on ios with no luck.
Thank you.
I figured out what the issue was. The call I was making to the api had an async http call which was returning after the api call was complete. Looks like ios doesn't like that. After making the http call sync the error was resolved.

asp.net mvc send httpstatuscode 200 but not return

I'm working on an asp.net mvc web app and am implementing paypal. I have everything working correctly with the IPN but paypal has a time limit of 30 seconds that it will wait for a response. I'm currently updating the customer database before return new HttpStatusCodeResult(HttpStatusCode.OK) Like I said, this works fine, however I was hoping to be able to send the status code so that I'm finished working with the ipn and paypal can finish listening then I will update the customer database in case something goes wrong in the update process and it takes longer than the 30 seconds. How can I send the HttpStatusCode but not return from the function? Any help is greatly appreciated.
You can't. 200 is a response status code. By sending 200, you are sending the response. The request-response cycle is then complete. If you need to take care of some long-running task, then you need to off-load it to a separate process. Look at something like Revalee.

Categories