Azure encoding job via REST Fails
Asked Answered
A

1

0

I am trying to upload a video and encode it via azure rest service. I have now hit the step of encoding the video but I am having difficulties with the request.

The following code shows my request:

 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);

the url:https://wamsamsclus001rest-hs.cloudapp.net/api/Jobs

the 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>"}]}

The bearer token works as I use it for other request.

But I get a bad request 400 with the followin error message:

{"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"}}}

Can anyone spot the error.

Thank you for the help

Absence answered 11/2, 2015 at 9:58 Comment(0)
A
3

Okay I got it to work. Needed a odata=verbose in my json/string content - like this:

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

I tried this earlier however I got a error 500 but now it is working.

Absence answered 11/2, 2015 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.