415 Unsupported Media type on Httpwebrequest.Getresponse -
i trying user profile data microsoft's live api performing httpwebrequest
https://apis.live.net/v5.0/me?access_token=myaccesstoken
however i'm getting unsupported media type error on getresponse()
.i thought might have been content-type, returns application-json
in postman. here's code:
var request =(httpwebrequest)httpwebrequest.create(string.format(@"https://apis.live.net/v5.0/me?access_token=" + smyaccesstoken)); request.contenttype = "application/json"; request.method = "get"; using (httpwebresponse response = request.getresponse() httpwebresponse) { using (streamreader reader = new streamreader(response.getresponsestream())) { var content = reader.readtoend(); dynamic result = jsonconvert.deserializeobject<dynamic>(content); if (result == null) { return null; } newtonsoft.json.linq.jobject socialprofileaccountresultjson = new newtonsoft.json.linq.jobject { ["firstname"] = result.first_name, ["surname"] = result.last_name, ["profilepictureurl"] = sprofilepictureurl }; return socialprofileaccountresultjson; } }
Comments
Post a Comment