2017-08-01 35 views
0

在我的上一个问题Azure Media Services Encoding Job Callback to URL中,建议在编码作业完成时,Azure媒体服务“支持WebHooks的通知功能”可用于回调URL。我有一些麻烦让这个工作。Azure媒体服务如何设置作业通知

采取的步骤:

  1. 创建和测试一个天青功能,其能够发送POST请求我的任意回调URL的。
  2. 使用REST API创建NotificationEndPoint并检索Id(类似于nb:nepid:UUID:e9203dcb-b6a0-4b44-3cc6-69c4a573bb8d)。
  3. 现在试图将通知添加到我的编码作业中。我对工作的JSON有效载荷创建REST API调用如下:

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

这一工程没有JobNotificationSubscriptions部分,但有了它,我只是得到了响应:

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

如何才能让我的通知与我的工作一起工作?

回答

0

我能解决这个问题,当我偶然发现这个职位从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

有通向成功此处为三个明显的因素:

  1. 在请求头,既DataServiceVersion和MaxDataServiceVersion需要设置为3.0。对我而言,情况已经如此,并且不需要改变,但对于试图解决相同问题的其他人而言,这可能很重要。
  2. InputMediaAssets性质需要改变的格式[email protected]":["https://wamsos1clus001rest-hs.cloudapp.net/api/Assets('nb%3Acid%3AUUID%3Acee6b356-a0d0-4cfa-955b-e81cbebebb8e')"],
  3. 在请求头,我需要从Content-Type=application/json;odata=verbose改变Content-Type=application/json

为什么这些因素都很重要时,要求作品,未经JobNotificationSubscriptions部分遗骸一个谜。