Sorry, you need to enable JavaScript to visit this website.

You are here

OAUTH and Provisioning issue

5 posts / 0 new
Last post

Bob's picture
by Bob

OAUTH and Provisioning issue
  {"access_token":"*********REDAC***********","token_type":"Bearer","expires_in":"3599"} testharness.js:822 access_token[****REDACTED*****] testharness.js:824 token_type[Bearer] testharness.js:825 expires_in[3599] testharness.js:826               No issues authenticating against the API, but every time i call it after Auth - and hit the provisioning method path: "/v2/messages/provisioning/subscriptions", I get the following, is anyone else getting that? testharness.js:892 {   "status":"400",   "code":"TECH-ERR",   "message":"Request flagged as containing invalid body. Request has been refused."   }  

Ian's picture
by Ian

I've come across this when
I've come across this when the body isn't properly formatted JSON. For example, in PHP setting the content type correctly and trying to send it as a JSON string doesn't work. Check that the format of the body is considered to be JSON rather than just looking like it.

DeveloperSteve's picture
by DeveloperSteve

Hi bob.j.reynolds

Are you using the JS SDK? What are you sending as your payload?

Bob's picture
by Bob

code snippet below.. vanilla
code snippet below.. vanilla node.js..   auths fine, I get an access token, fails on provision..   function provisionNumber(sAccessToken) { /*   #!/bin/bash curl -X POST \   https://tapi.telstra.com/v2/messages/provisioning/subscriptions \   -H 'authorization: Bearer $ACCESS_TOKEN' \   -H 'cache-control: no-cache' \   -H 'content-type: application/json' \   -d '{   "activeDays":30,   "notifyURL":"http://example.com/callback",   "callbackData":   {     "anything":"some data"   } */ var post_data = querystring.stringify({   activeDays : '30' }); var req_options =  {   host: 'tapi.telstra.com',   port: 443,   path: "/v2/messages/provisioning/subscriptions",   method: 'POST',   headers:    {     authorization : 'Bearer ' + sAccessToken,     'cache-control' : 'no-cache',     'content-type' : 'application/json'   } }; console.log (req_options); var reqR = https.request(req_options, function(response)  {   // Continuously update stream with data   var body = '';   response.on('data', function(d)    {       body += d;   });   // The whole response has been received. Print out the result.   response.on('end', () =>    {     console.log(body);     if (response.statusCode==200)     {       console.log(body)           var oJson = JSON.parse(body);     }     //cb(body);   }).on("error", (err) =>    {     debug("Error interacting with API: " + err.message );   });  }); reqR.write(post_data); reqR.end();   }    

Bob's picture
by Bob

Vanilla Node.js...
Vanilla Node.js... found my issue.. had var post_data = querystring.stringify({ activeDays : '30' }); should have had var post_data = JSON.stringify({ activeDays : '30' });
Log in or register to post comments