0

I am able to create a Case in SalesCloud using Postman. However, with the same JSON payload this is failing from my CloudPage using SSJS (note that I retrieve the token successfully in the same page)

When I try

  var result = HTTP.Post(endpoint, "application/json", payload, ["Cache-Control", "Authorization"], ["no-cache", "Bearer " + token]);  

I get {"message":"Unable to retrieve security descriptor for this frame.","description":"System.InvalidOperationException: Unable to retrieve security descriptor for this frame. - from mscorlib\r\n\r\n"}

I also tried by converting the payload to form data (this worked for the token retrieval..)

 var result = HTTP.Post(endpoint, "application/x-www-form-urlencoded", payload, ["Cache-Control", "Authorization"], ["no-cache", "Bearer " + token]); 

But I get error {"message":"An error occurred when attempting to evaluate a HTTPPost function call. See inner exception for details.","description":"ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a HTTPPost function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nSystem.Net.WebException: The remote server returned an error: (415) Unsupported Media Type. - from System\r\n\r\n\r\n\r\n"}

What's the correct way of doing this?

4

1 Answer 1

0

It's solved:

  1. Blank space after Bearer is needed.

  2. Stringify the payload

     var payload =  Stringify(payload)
        var result = HTTP.Post(endpoint, "application/json", payload, ["Cache-Control", "Authorization"], ["no-cache", "Bearer " + token]); 
    
          if (result.StatusCode == 200) {
                        Write("Case created " + Stringify(Platform.Function.ParseJSON(result.Response[0])));          
    
          } else { Write ("</br> oh, there was an error "); }
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .