0

I am only getting this error when trying to recover the client ID and Client secret from the D.E, if I set them manually I can get the accesstoken, This is my AMPScript in the cloud page :

    **%%[
       var @rows, @row, @rowCount, @Rank, @payload
       set @Rank = "1" 
set @rows = LookupRows("Client-Credentials","Rank", @Rank)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
  var @clientsecret, @clientid
  set @row = row(@rows,1) /* get row #1 */
  set @clientid = field(@row,"client-id")
  set @clientsecret = field(@row,"client-secret")
]%%
%%[ else ]%%
No rows found
%%[ endif ]%%
%%[
var @payload, @postRequest, @response, @responseRows,  @title, @text, @insertcount
set @payload = concat("{","<br>")
  set @payload = concat(@payload,"""clientID""", ":",char(34),@clientid,char(34),",","<br>")
  set @payload = concat(@payload,"""clientSecret""", ":",char(34),@clientsecret,char(34),"<br>")
  set @payload= concat(@payload, "}")
  set @payload2 = replace(@payload, " ")
  set @postrequest = HTTPPost2("https://subdomain.auth.marketingcloudapis.com/v1/requestToken","application/json", @payload, true, @response, @responseRows) 
]%%
]%%
%%=v(@payload2)=%%
%%=v(@postrequest)=%%**
  • 1
    What is the error? Have you verified that the lookup to the DE is returning correct values? – Gortonington Apr 20 at 20:27
  • I would print you var clientid clientsecret to ensure the correct values are returned – EazyE Apr 21 at 22:44
  • Yes, I have seen the output from my lookup, the client id and client secret are passing on correctly, the cloud page only fails when I am doing the PostRequest. I tried changing the payload format but nothing really works – Kumar Apr 28 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.