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
kundan sakpal
NA
6
2.1k
Consume webservice data using 2headers in c#
Jul 17 2015 8:36 AM
How do i Consume Rest Webservice data by HttpWebRequest/WebClient using Headers?
Here is my code:-
using
(
var
clients
=
new
HttpClient
())
{
//
clients
.
DefaultRequestHeaders
.
UserAgent
.
ParseAdd
(
UserAgent
)
;
var
a
=
"mywebserviceurl"
+
"
AbsenceOdata
"
;
var
requests
=
new
HttpRequestMessage
()
{
RequestUri
=
new
Uri
(
a
)
,
Method
=
HttpMethod
.
Get
,
}
;
//
requests
.
Headers
.
Add
(
"
Content
-
Type
"
,
"
application
/
xml
"
)
;
requests
.
Headers
.
Add
(
"
X
-
SMP
-
APPCID
"
,
"
84004aa6
-
554b
-
47cb
-
b9a9
-
1c9fc8874cd8
"
)
;
requests
.
Headers
.
Add
(
"
X
-
CSRF
-
Token
"
,
"
FETCH
"
)
;
var
responseMessage
=
await
clients
.
SendAsync
(
requests
)
;
var
responses
=
await
responseMessage
.
Content
.
ReadAsStringAsync
()
;
var
json
=
await
clients
.
GetStringAsync
(
requests
.
RequestUri
)
;
if
(
responseMessage
.
IsSuccessStatusCode
)
{
var
jObject
=
JObject
.
Parse
(
responses
)
;
var
r
=
JsonConvert
.
DeserializeObject
<
ArrayOfAbsenceDTO
>(
jObject
.
ToString
())
;
}
}
Reply
Answers (
2
)
Fetching data from URL and saving in a seperate text file
block not hide taskbar c#