string requestPath = "http://host/user/register";
string RegJson = JsonConvert.SerializeObject(userProfile);
WebRequest request = WebRequest.Create(requestPath);
request.Headers.Add("UserID:"+ userID +";");
request.Headers.Add("Password:" + password + ";");
request.ContentType = "application/json; charset=utf-8";
request.Method = "POST";
Here userprofile i am converting to json and use that for the webrequest call. After registration and login, i need to include userID and password in the header for every request. I’m not sure weather I am passing UserID & Password properly in the header or not.
IT SHOULD APPEAR AS BELOW IN HEADER:
POST /MyURL/ HTTP/1.1
Host hostname
Content-Length 396
Origin chrome-extension://cokgbflfommojglbmbpenpphppikmonn
UserID 12345
Password 98765abc
User-Agent Mozilla/5.0
AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11
Content-Type application/json
Accept /
Accept-Encoding gzip,deflate,sdch
Accept-Language en-US,en;q=0.
I tried request.Headers.Add(“UserID:”+ userID_Value +”;”);
you don’t need semicolon in the web request, you just need to add as a string.