I am using azure mobile service, i am sending auth token with request. Get request is working from client, But when i am trying to hit POST request it's throwing exception "The remote server returned an error: (405) Method Not Allowed." event i am binding auth token with request. Here is my code:-
> string result = string.Empty;
> request.ContentType = "application/json";
> request.Method = "POST";
>
> if (!string.IsNullOrEmpty(requestData))
> {
> UTF8Encoding encoder = new UTF8Encoding();
> byte[] data = encoder.GetBytes(requestData);
> Task.Factory.FromAsync<System.IO.Stream>(request.BeginGetRequestStream,
> request.EndGetRequestStream, null).Result.Write(data, 0, data.Length);
> }
>
> request.Headers["x-zumo-auth"] = auth_token;
> request.Headers["ZUMO-API-VERSION"] = "2.0.0";
> try
> {
>
>
> WebResponse webResponse = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse,
> request.EndGetResponse, null).Result;
> using (var streamReader = new StreamReader(webResponse.GetResponseStream()))
> {
> result = streamReader.ReadToEnd();
> }
> }
> catch (Exception ex)
> {
>
> throw;
> }
If anybody have any idea please share with me. I have tried the same request with Postman, that is working. Same way i am using for "Get" request.
That means, the server does not support POST
requests for that url. Maybe you need GET
or PUT
. Does not have anything to do with authentication.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.