The remote server returned an error: “(405) Method Not Allowed”
After reading different answers against the same thread i tried almost all the options mentioned in their discussions however i am still getting error:
Error No1: The remote server returned an error: (404) Not Found.
OR
Error No2:The remote server returned an error: (405) Method Not Allowed
.
Below is my code:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&user=u1&password=p1");
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
I receive error on the last line i.e.
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
If i use httpWebRequest.Method="GET"
i receive the error number 1 as mentioned above and if i use httpWebRequest.Method="Post"
i receive the error number 2.
c#
|
show 10 more comments
After reading different answers against the same thread i tried almost all the options mentioned in their discussions however i am still getting error:
Error No1: The remote server returned an error: (404) Not Found.
OR
Error No2:The remote server returned an error: (405) Method Not Allowed
.
Below is my code:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&user=u1&password=p1");
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
I receive error on the last line i.e.
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
If i use httpWebRequest.Method="GET"
i receive the error number 1 as mentioned above and if i use httpWebRequest.Method="Post"
i receive the error number 2.
c#
Where are you returning the json from?
– Nicklas Pouey-Winger
Apr 22 '14 at 8:10
Can you be more specific ... ??? i am returning it from server (ofcourse)
– amw
Apr 22 '14 at 8:16
I suppose that you do not know the calling method if is post or get? EDIT: Do you know what are the parameters of the web call?
– kostas ch.
Apr 22 '14 at 8:17
1
Yes, but how does the returning method look? Not really sure what you mean, but when I return json from my controllers, I need to add aJsonRequestBehaviour.AllowGet
as part of my returned result.
– Nicklas Pouey-Winger
Apr 22 '14 at 8:18
@kostasch. infact i do know its post.. but alot of other threads where saying we should change it here and there to see if it works..thats why i already mentioned it in my question, otherwise its "post" which you can in my code.
– amw
Apr 22 '14 at 8:21
|
show 10 more comments
After reading different answers against the same thread i tried almost all the options mentioned in their discussions however i am still getting error:
Error No1: The remote server returned an error: (404) Not Found.
OR
Error No2:The remote server returned an error: (405) Method Not Allowed
.
Below is my code:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&user=u1&password=p1");
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
I receive error on the last line i.e.
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
If i use httpWebRequest.Method="GET"
i receive the error number 1 as mentioned above and if i use httpWebRequest.Method="Post"
i receive the error number 2.
c#
After reading different answers against the same thread i tried almost all the options mentioned in their discussions however i am still getting error:
Error No1: The remote server returned an error: (404) Not Found.
OR
Error No2:The remote server returned an error: (405) Method Not Allowed
.
Below is my code:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&user=u1&password=p1");
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
I receive error on the last line i.e.
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
If i use httpWebRequest.Method="GET"
i receive the error number 1 as mentioned above and if i use httpWebRequest.Method="Post"
i receive the error number 2.
c#
c#
edited Sep 25 '18 at 22:02
jelhan
2,4901824
2,4901824
asked Apr 22 '14 at 8:08
amwamw
16114
16114
Where are you returning the json from?
– Nicklas Pouey-Winger
Apr 22 '14 at 8:10
Can you be more specific ... ??? i am returning it from server (ofcourse)
– amw
Apr 22 '14 at 8:16
I suppose that you do not know the calling method if is post or get? EDIT: Do you know what are the parameters of the web call?
– kostas ch.
Apr 22 '14 at 8:17
1
Yes, but how does the returning method look? Not really sure what you mean, but when I return json from my controllers, I need to add aJsonRequestBehaviour.AllowGet
as part of my returned result.
– Nicklas Pouey-Winger
Apr 22 '14 at 8:18
@kostasch. infact i do know its post.. but alot of other threads where saying we should change it here and there to see if it works..thats why i already mentioned it in my question, otherwise its "post" which you can in my code.
– amw
Apr 22 '14 at 8:21
|
show 10 more comments
Where are you returning the json from?
– Nicklas Pouey-Winger
Apr 22 '14 at 8:10
Can you be more specific ... ??? i am returning it from server (ofcourse)
– amw
Apr 22 '14 at 8:16
I suppose that you do not know the calling method if is post or get? EDIT: Do you know what are the parameters of the web call?
– kostas ch.
Apr 22 '14 at 8:17
1
Yes, but how does the returning method look? Not really sure what you mean, but when I return json from my controllers, I need to add aJsonRequestBehaviour.AllowGet
as part of my returned result.
– Nicklas Pouey-Winger
Apr 22 '14 at 8:18
@kostasch. infact i do know its post.. but alot of other threads where saying we should change it here and there to see if it works..thats why i already mentioned it in my question, otherwise its "post" which you can in my code.
– amw
Apr 22 '14 at 8:21
Where are you returning the json from?
– Nicklas Pouey-Winger
Apr 22 '14 at 8:10
Where are you returning the json from?
– Nicklas Pouey-Winger
Apr 22 '14 at 8:10
Can you be more specific ... ??? i am returning it from server (ofcourse)
– amw
Apr 22 '14 at 8:16
Can you be more specific ... ??? i am returning it from server (ofcourse)
– amw
Apr 22 '14 at 8:16
I suppose that you do not know the calling method if is post or get? EDIT: Do you know what are the parameters of the web call?
– kostas ch.
Apr 22 '14 at 8:17
I suppose that you do not know the calling method if is post or get? EDIT: Do you know what are the parameters of the web call?
– kostas ch.
Apr 22 '14 at 8:17
1
1
Yes, but how does the returning method look? Not really sure what you mean, but when I return json from my controllers, I need to add a
JsonRequestBehaviour.AllowGet
as part of my returned result.– Nicklas Pouey-Winger
Apr 22 '14 at 8:18
Yes, but how does the returning method look? Not really sure what you mean, but when I return json from my controllers, I need to add a
JsonRequestBehaviour.AllowGet
as part of my returned result.– Nicklas Pouey-Winger
Apr 22 '14 at 8:18
@kostasch. infact i do know its post.. but alot of other threads where saying we should change it here and there to see if it works..thats why i already mentioned it in my question, otherwise its "post" which you can in my code.
– amw
Apr 22 '14 at 8:21
@kostasch. infact i do know its post.. but alot of other threads where saying we should change it here and there to see if it works..thats why i already mentioned it in my question, otherwise its "post" which you can in my code.
– amw
Apr 22 '14 at 8:21
|
show 10 more comments
3 Answers
3
active
oldest
votes
Use:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "abcxx")]
At your service page where you declare your method, type POST
in upper case. I think you are typing in lowercase.
add a comment |
I too face this issue. Root cause of this error is may be mistook endpoint address in web config file..
This is my mistaken web config
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
It should be like this
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335/sample.svc" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
Now its working fine... Best is yours.. Good Luck.
add a comment |
My bet is that either Paramter1 or username or password are incorrect - in other words the user you were trying to use doid not exist.
The server returns 404 Not Found, not because you didn't hit the right API method, but because the object you are asking for doesn't exist.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23213967%2fthe-remote-server-returned-an-error-405-method-not-allowed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "abcxx")]
At your service page where you declare your method, type POST
in upper case. I think you are typing in lowercase.
add a comment |
Use:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "abcxx")]
At your service page where you declare your method, type POST
in upper case. I think you are typing in lowercase.
add a comment |
Use:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "abcxx")]
At your service page where you declare your method, type POST
in upper case. I think you are typing in lowercase.
Use:
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "abcxx")]
At your service page where you declare your method, type POST
in upper case. I think you are typing in lowercase.
edited Nov 22 '14 at 7:02
Unihedron
9,352104762
9,352104762
answered Nov 22 '14 at 6:34
Alam UsmaniAlam Usmani
734
734
add a comment |
add a comment |
I too face this issue. Root cause of this error is may be mistook endpoint address in web config file..
This is my mistaken web config
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
It should be like this
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335/sample.svc" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
Now its working fine... Best is yours.. Good Luck.
add a comment |
I too face this issue. Root cause of this error is may be mistook endpoint address in web config file..
This is my mistaken web config
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
It should be like this
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335/sample.svc" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
Now its working fine... Best is yours.. Good Luck.
add a comment |
I too face this issue. Root cause of this error is may be mistook endpoint address in web config file..
This is my mistaken web config
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
It should be like this
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335/sample.svc" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
Now its working fine... Best is yours.. Good Luck.
I too face this issue. Root cause of this error is may be mistook endpoint address in web config file..
This is my mistaken web config
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
It should be like this
<services>
<service behaviorConfiguration="mexBehavior" name="sample.sample">
<endpoint address="http://xxx.xxx.x.xxx:9335/sample.svc" binding="basicHttpBinding" contract="sample.Isamplebase" />
<host>
<baseAddresses>
<add baseAddress="http://xxx.xxx.x.xxx:9335" />
</baseAddresses>
</host>
</service>
</services>
Now its working fine... Best is yours.. Good Luck.
answered Oct 14 '15 at 9:29
Madhu McaMadhu Mca
111
111
add a comment |
add a comment |
My bet is that either Paramter1 or username or password are incorrect - in other words the user you were trying to use doid not exist.
The server returns 404 Not Found, not because you didn't hit the right API method, but because the object you are asking for doesn't exist.
add a comment |
My bet is that either Paramter1 or username or password are incorrect - in other words the user you were trying to use doid not exist.
The server returns 404 Not Found, not because you didn't hit the right API method, but because the object you are asking for doesn't exist.
add a comment |
My bet is that either Paramter1 or username or password are incorrect - in other words the user you were trying to use doid not exist.
The server returns 404 Not Found, not because you didn't hit the right API method, but because the object you are asking for doesn't exist.
My bet is that either Paramter1 or username or password are incorrect - in other words the user you were trying to use doid not exist.
The server returns 404 Not Found, not because you didn't hit the right API method, but because the object you are asking for doesn't exist.
answered Oct 24 '16 at 23:09
tymtamtymtam
6,77733657
6,77733657
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f23213967%2fthe-remote-server-returned-an-error-405-method-not-allowed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where are you returning the json from?
– Nicklas Pouey-Winger
Apr 22 '14 at 8:10
Can you be more specific ... ??? i am returning it from server (ofcourse)
– amw
Apr 22 '14 at 8:16
I suppose that you do not know the calling method if is post or get? EDIT: Do you know what are the parameters of the web call?
– kostas ch.
Apr 22 '14 at 8:17
1
Yes, but how does the returning method look? Not really sure what you mean, but when I return json from my controllers, I need to add a
JsonRequestBehaviour.AllowGet
as part of my returned result.– Nicklas Pouey-Winger
Apr 22 '14 at 8:18
@kostasch. infact i do know its post.. but alot of other threads where saying we should change it here and there to see if it works..thats why i already mentioned it in my question, otherwise its "post" which you can in my code.
– amw
Apr 22 '14 at 8:21