TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gopi Krishnan
NA
308
7.7k
Web API Consuming
Oct 21 2019 5:06 AM
Error "Cannot send a content-body with this verb-type."
When i call API to invoke GET Method with json parmater using Httpwebrequest class,i got the above error.kindly share any solution.
url =
"xxxxx"
;
Uri myUri =
new
Uri(url);
strUserName =
"test"
;
strPassword =
"*******"
;
WebRequest myWebRequest = HttpWebRequest.Create(myUri);
HttpWebRequest webReqStatus = (HttpWebRequest)myWebRequest;
NetworkCredential myNetworkCredential =
new
NetworkCredential(strUserName, strPassword);
CredentialCache myCredentialCache =
new
CredentialCache();
myCredentialCache.Add(myUri,
"Digest"
, myNetworkCredential);
webReqStatus.PreAuthenticate =
true
;
webReqStatus.Credentials = myCredentialCache;
//webRequest.Headers.Add("authentication", "DIGEST");
webReqStatus.ContentType =
"application/json"
;
//webRequest.Headers.Add("Authorization", "DIGEST");
webReqStatus.Method =
"GET"
;
webReqStatus.KeepAlive =
true
;
//webReqHelloCash.Timeout = 10000;
//webReq.Headers.Add("cache-control", "no-cache");
PartouchePaymentRequest objReqStatus =
new
PartouchePaymentRequest();
objReqStatus.idFromClient = id;
objReqStatus.loginAgent =
"7895"
;
objReqStatus.passwordAgent =
"0000"
;
try
{
var _postDataPaymentStatus = JsonConvert.SerializeObject(objReqStatus);
byte
[] bytedata = Encoding.ASCII.GetBytes(_postDataPaymentStatus);
webReqStatus.ContentLength = bytedata.Length;
Stream requestStream = webReqStatus.GetRequestStream();
requestStream.Write(bytedata, 0, bytedata.Length);
requestStream.Close();
HttpWebResponse webResp_PaymentStatus = (HttpWebResponse)webReqStatus.GetResponse();
resposeCode = (
int
)webResp_PaymentStatus.StatusCode;
using
(var streamReader =
new
StreamReader(webResp_PaymentStatus.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
catch
()
Reply
Answers (
3
)
Dynamically populate Menu from database as mob Responsively
Fetch top 50 records from xml