Azure失败的Azure编码工作

时间:2015-02-11 09:58:21

标签: rest azure azure-media-services

我正在尝试上传视频并通过azure rest服务对其进行编码。 我现在已经开始编码视频,但我对请求有困难。

以下代码显示了我的请求:

 var joburl = res.RequestMessage.RequestUri + "Jobs";
        client = new HttpClient();
        client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + token);
        client.DefaultRequestHeaders.Add("x-ms-version", "2.8");
        client.DefaultRequestHeaders.Add("DataServiceVersion", "3.0");
        client.DefaultRequestHeaders.Add("MaxDataServiceVersion", "3.0");
        client.DefaultRequestHeaders.Add("x-ms-date", date);

        //accept
        t = new NameValueHeaderValue("odata", "verbose");
        type = new MediaTypeWithQualityHeaderValue("application/json");
        type.Parameters.Add(t);
        client.DefaultRequestHeaders.Accept.Add(type);

        result = await client.PostAsync(joburl,json);

网址:https://wamsamsclus001rest-hs.cloudapp.net/api/Jobs

json:

{"Name":"khgfiuydencodingjob","InputMediaAssets":[{"__metadata":{"Uri":"https://wamsamsclus001rest-hs.cloudapp.net/api/Assets('nb%3acid%3aUUID%3ad037b321-cd1c-43a9-9607-c4910fa7a85b')"}}],"Tasks":[{"Configuration":"H264 Adaptive Bitrate MP4 Set 720p","MediaProcessorId":"nb:mpid:UUID:1b1da727-93ae-4e46-a8a1-268828765609","TaskBody":"<?xml version=\"1.0\"encoding=\"utf-8\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"}]}

当我将其用于其他请求时,承载令牌起作用。

但是我收到了一条错误的请求400,其中包含以下错误消息:

{"error":{"code":"","message":{"lang":"en-US","value":"Parsing request content failed due to: Make sure to only use property names that are defined by the type"}}}

任何人都可以发现错误。

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

好的,我让它上班了。在我的json / string内容中需要odata = verbose - 就像这样:

var jobInJson = JsonConvert.SerializeObject(job);
       json = new StringContent(jobInJson, Encoding.UTF8);//, 
       json.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json;odata=verbose");

我之前尝试过这个但是我收到错误500但是现在它正在运行。