How to perform POST method in WebAPI in C# - c#

I have created GET,POST,PUT and DELETE methods in my sample Web api.
Using fiddler, I am adding resources using POST method and getting status 201 created with location.
But when I am calling through its URI, I am getting not found exception.

You probably call the POST-method with a GET http method. Then you get a 4xx error.
I suggest using a "Advanced REST client" (search google- chrome plugin) to post your data. Then you can use the right HTTP methods in your web api.

Related

Unable to redirect to specified url results in 405 error

Hi I am developing payment page using webapi2 and angularjs. my payment api contains field called redirecturl. redirecturl will be used when payment is successful user will be redirect to this page. I have created simple html page called redirectpage.html and it can be accessed as http://localhost:10963/redirectpage.html. My payment api works fine and i am getting success in response. I am able to redirect to http://localhost:10963/redirectpage.html but i am getting HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. May i know possible cause for this? Thanks in advance.
As you said, payment api sends a POST call to redirecturl, you should have some server side code in place, to accept POST calls. Plain html pages can accept only GET calls. If you want to redirect to plain html page, please check payment api's docs, how to redirect using query parameters in the url.

GET Request - Invalid HOST - ASP WEB API 2

I uploaded my ASP.NET Web API 2 project onto the web using Azure.
But now that I have uploaded it (it is http), I cant get the GET request to work.
The problem is the Host parameter.
In the URL feild i put: www.website.com/api/Parts
I put the website URL in the Host Value field: www.website.com
This doesnt seem like a CORS issue.
How do I send a GET request to the online API?
looks like you are testing in POSTMAN. Just remove the Host parameter from header and test/send your API request again.
Postman can not override Host header, it is blocked by default.
To allow Postman to send this header, install Postman Interceptor extension

(404) Not Found in twitter login

I'm creating a twitter login api for our mobile web application. I got this 404 not found error as return message in console. this is the full url for twitter callback
https://api.twitter.com/?oauth_callback=http%3A%2F%2F127.0.0.1%3A4268%2Fmobileapp%2F&oauth_consumer_key=<keyhere>&oauth_nonce=7540630&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1396766598&oauth_version=1.0&oauth_signature=9TjVwKWGyqYEGYdfl1s56k%2BCaaY%3D
is there something wrong with the return url?
thanks
No, the problem is not in the return url.
The problems are:
You're sending the URL to https://api.twitter.com/ without any further URI to indicate the service that you're requesting. Since you are passing an oauth_callback, it's likely that you wanted to access https://api.twitter.com/oauth/request_token
You can't pass an oauth_callback to oauth/request_token using a GET request: you need to use a POST request instead.
Hopefully that explains for you what's wrong with this URL.
If you are having more problems accessing the Twitter oauth API, I suggest that you read this primer from Twitter on how to use this API:
Implementing Sign in with Twitter

How to get the soap request going out with the call using wsdl c#?

Very new to this. I am using a wsdl. Generating the web reference and .net builds the classes in references.cs. Now is there any way I can get the soap request going out though any c# methods in my code?
Getting at System.Xml.Serialization.XmlSerializer.Serialize error in prod but absolutely working fine in UAT. No body has no clue on why? Can someone pls provide insights on getting the soap request going out ?
You can use tool fiddler to track the request and responce

Foursquare (411) Length Required error with SharpSquare api

We've been using the Foursquare SharpSquare api to add checkins with success. We recently noticed that we're getting a "(411) Length Required" error. We get this error most of the time now, but once in a while it will post successfully. The general consensus to fix this error seem to be to add Content-Length=0 to the header, but i'm not sure if that's possible with SharpSquare. Any ideas?
It sounds like the SharpSquare api does not properly add a Content-length header. If this is not possible from using the SharpSquare API, you may need to update the SharpSquare source so this is performed correctly, or craft your own HTTP request without using the SharpSquare API.

Categories