none
generate job to generate sprite thumbnail on azure media service with node.js RRS feed

  • Question

  • i generate this request to generate sprite thumbnail on azure media service with node.js 
    This is request:

    var request=require("request")

    const bodyParser = require('body-parser');

    var request2 = require('ajax-request');

    var headers = {

        'Content-Type': 'application/x-www-form-urlencoded',

        'Host':'login.microsoftonline.com'

    };

    var url = 'https://login.microsoftonline.com/********/oauth2/token';

    var form = {

        "grant_type":"client_credentials",

        "client_id":"********",

        "client_secret":"*********",

        "resource":"https://rest.media.azure.net"

    };

    request({headers: headers, url: url, form: form, method: 'POST'}, function (e, r, body) {

        var bearerToken=JSON.parse(body)

            var header3={

              'Accept': 'application/json;odata=verbose',

              'Authorization':'Bearer '+bearerToken.access_token,

              'Connection': 'keep-alive',

              'Content-Type': 'application/json;odata=verbose',

              'DataServiceVersion': '3.0',

              'Host': '*******.restv2.westeurope.media.azure.net',

              'MaxDataServiceVersion': '3.0',

              'cache-control': 'no-cache,no-cache',

              'content-length': '1043',

              'x-ms-version': '2.9'

            }

           var url3="https://*******.restv2.westeurope.media.azure.net/api/Jobs"

           var config={

            "Version": 1.0,

            "Codecs": [

            {

              "Start": "00:00:01",

              "Type": "JpgImage",

              "Step": "5%",

              "Range": "100%",

              "JpgLayers": [

                {

                  "Type": "JpgLayer",

                  "Width": "10%",

                  "Height": "10%",

                  "Quality": 90

                }

              ],

              "SpriteColumn": 10

            }

              ],

              "Outputs": [

                {

                  "FileName": "{Basename}_{Index}{Extension}",

                  "Format": {

                    "Type": "JpgFormat"

                  }

                }

           ]

        }

        var obj={

            "Name": "Thumbnails",

            "InputMediaAssets" : [{"__metadata": {"uri" : "https://******.restv2.westeurope.media.azure.net/api/Assets('*******')"}}],

           "Tasks" : [{

            "Configuration" :"H264 Multiple Bitrate 1080p",

           "MediaProcessorId":"nb:mpid:UUID:ff4df607-d419-42f0-bc17-a481b1331e56",

           "TaskBody": "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(1)</outputAsset></taskBody>"}]

       

        }

           

        request2.post({

            url: 'url3',

            headers:header3,

            body:JSON.stringify(obj)

          },function(e,r,body){

              console.log(body)

          });

    })
    And the request is :

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>400 Bad Request</title>

    </head><body>
    <h1>Bad Request</h1>
    <p>Your browser sent a request that this server could not understand.<br />
    </p>
    </body></html>

    can you help me to solve this problem
    Thanks

    Tuesday, June 18, 2019 11:39 AM