0

I'm trying to troubleshoot but I'm struggling. It code below works in postman, but not in the ampscript function:

Set @req_url = "[URL]"
Set @content_type = "application/json"

Var @body, @json, @response
    
    Set @bearerToken = Concat('Bearer ', @access_token)
    Set @body = "{"transactionId": 12345,"startingDate": "2023-09-23","numberDays": 0}"
    
set @post = HTTPPost2(@req_url,@content_type, @body, false, @json, @response,"Authorization",@bearerToken,"x-program-id","...")
6
  • 2
    Try changing the outer/wrapping quote marks around your entire JSON string from double to single quotes.
    – Mark G
    Jul 21, 2023 at 0:16
  • 1
    As @MarkG said. Its because you are using double quotes around your @body variable. This is breaking as its opening and closing on each double quote inside. Using Single quotes instead will resolve this. Jul 21, 2023 at 0:43
  • I did change it and it still didn't work.
    – en-rep
    Jul 21, 2023 at 15:22
  • 1
    @en-rep is the value for @req_url literally "[URL]" right now or is that just a placeholder for this example? If URL is the name of the actual attribute, though, the quotes there will need to be removed.
    – Mark G
    Jul 21, 2023 at 17:55
  • 1
    After the HTTPPost2 function, try outputting the post, json, and response variables to see what they contain. This may give you more information about what is going wrong. Jul 22, 2023 at 2:10

0

You must log in to answer this question.

Browse other questions tagged .