1
votes

In my previous question Azure Media Services Encoding Job Callback to URL it is suggested that Azure Media Services "Notifications features which supports WebHooks" can be made to callback to a URL when an encoding job is completed. I'm having a bit of trouble getting this to work.

Steps taken:

  1. Created and tested an Azure function which is capable of sending a POST request to my arbitrary callback URL.
  2. Used REST API to create a NotificationEndPoint and retrieved the Id (which is something like nb:nepid:UUID:e9203dcb-b6a0-4b44-3cc6-69c4a573bb8d).
  3. Now trying to get the notification added to my encoding job. My JSON payload for the Job create REST API call is as follows:

{
    "Name": "TestJob",
    "InputMediaAssets" : [
        {
            "__metadata" : {"uri" : "https://media.windows.net/api/AssetsAssets('nb%3Acid%3AUUID%3A3679cd1f-74ba-4374-8d4b-8c26feba4e1d')"}
        }
    ],
    "JobNotificationSubscriptions": [
        {
            "NotificationEndPointId": "nb:nepid:UUID:e9203dcb-b6a0-4b44-3cc6-69c4a573bb8d",
            "TargetJobState": 1
        }
    ],
    "Tasks": [
        {
            "Configuration": "Adaptive Streaming",
            "MediaProcessorId": "nb:mpid:UUID:fa4df505-d219-42b0-bc17-a481c1441e56",
            "TaskBody": "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"
        }
    ]
}

That works without the JobNotificationSubscriptions section but with it, I simply get the response:

   "error": {
        "code": "",
        "message": {
            "lang": "en-US",
            "value": "An error occurred while processing this request."
        }
    }

How can I get my notification working with my job?

1

1 Answers

2
votes

I was able to solve this problem when I happened upon this post from 2014: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/cc69a85f-74b0-4d52-8e69-629ff5007169/create-an-encoding-job-with-jobnotificationsubscriptions-by-using-rest-api-got-a-response-with-400?forum=MediaServices

There are three apparent factors leading to success here:

  1. In the request header, both DataServiceVersion and MaxDataServiceVersion need to be set to 3.0. This was already the case for me and didn't need to be changed, but it could be important for others trying to solve the same problem.
  2. The InputMediaAssets property needed to be changed to the format [email protected]":["https://wamsos1clus001rest-hs.cloudapp.net/api/Assets('nb%3Acid%3AUUID%3Acee6b356-a0d0-4cfa-955b-e81cbebebb8e')"],
  3. In the request header, I needed to change from Content-Type=application/json;odata=verbose to Content-Type=application/json

Why these factors are important when the request works without the JobNotificationSubscriptions section remains a mystery.