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
PP Smartwork
NA
8
17.8k
how to call web api in asp.net c# code behind
Mar 27 2018 10:24 AM
string
json =
"{\"clientName\":\"test12\"}"
;
var httpWebRequest = (HttpWebRequest)WebRequest.Create(
"https://test/api/ClientID.pdo"
);
httpWebRequest.ContentType =
"application/json"
;
httpWebRequest.Accept =
"application/json"
;
httpWebRequest.Method =
"POST"
;
string
credentials =
"XYZ:XYZ"
;
httpWebRequest.Headers.Add(
"Authorization"
,
"basic"
+ credentials);
using
(var streamWriter =
new
StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using
(var streamReader =
new
StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
var res =
new
JavaScriptSerializer().Deserialize<Response>(result);
int
clientID = res.clientID;
//return res;
}
I am getting clientID=0.
Plz help me.
Reply
Answers (
3
)
Information to know best site learning asp.net
help me please how can edit listview data with backend code