400 Bad request while uploading video to youtube using REST API in Windows Phone 8.1 -


below given code uploading video youtube using rest api in windows phone 8.1. have followed guide here. returns me 400 bad request error json (which given after code). has idea wrong in code?

public async task uploadvideoasync(token authtoken) {     string json = @"{                         ""snippet"": {                         ""title"": ""using api"",                         ""description"": ""this description of video"",                         ""tags"": [""cool"", ""video"", ""more keywords""],                         ""categoryid"": 21,                         },                         ""status"": {                         ""privacystatus"": ""public"",                         ""embeddable"": true,                         ""license"": ""youtube""                         }                     }";      var jsonreqmsg = new httpstringcontent(json);      jsonreqmsg.headers.contenttype = new windows.web.http.headers.httpmediatypeheadervalue("application/json")      {         charset = "utf-8"     };      ulong reqsize = 0;     jsonreqmsg.trycomputelength(out reqsize);     jsonreqmsg.headers.contentlength = reqsize;      var videofile = await storagefile.getfilefromapplicationuriasync(new uri("ms-appx:///assets/test.mp4"));     var prop = await videofile.getbasicpropertiesasync();      var request = new httprequestmessage(httpmethod.post, new uri("https://www.googleapis.com/upload/youtube/v3/videos?uploadtype=resumable&part=snippet,status"));     request.headers.add("x-upload-content-length", prop.size.tostring());     request.headers.add("x-upload-content-type", "video/*");     request.content = jsonreqmsg;      var httpclient = new httpclient();     httpclient.defaultrequestheaders.add("authorization", authtoken.tokentype + " " + authtoken.accesstoken);      var uploadreq = await httpclient.sendrequestasync(request);     if (uploadreq.issuccessstatuscode)     {         string _videourl = string.empty;         var res = await uploadreq.content.readasstringasync();         uploadreq.headers.trygetvalue("location", out _videourl);          var binarycontent = new httpbuffercontent(await fileio.readbufferasync(videofile));         var uploadreq_ = await httpclient.putasync(new uri(_videourl), binarycontent);         if (uploadreq_.issuccessstatuscode)         {             var res_ = await uploadreq_.content.readasstringasync();         }     } } 

error json

{  "error": {   "errors": [    {     "domain": "global",     "reason": "parseerror",     "message": "parse error"    }   ],   "code": 400,   "message": "parse error"  } } 

youtube api documentation has error in sample json request. categoryid value string not int & embeddable key has true value. should true, without capital t.

check out also: youtube api video upload parse error in c#


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -