Search code examples
authenticationpostrequesthttp-headerslivecode

Livecode httpHeader


Can someone guide me the appropriate way of sending the httpHeaders below. Am getting "Permission Denied" as responds from the server but all looks good with my code.

put "ABCD" into clientId
put "1234" into clientSecret

put "Authorization: Basic" && base64Encode("clientId:clientSecret") && "Content-Type: application/json"&& "Cache-Control: no-cache"  into tHeader 
set the httpHeaders to tHeader

 post receiveMomoRequest to url "https://server/v1/merchantaccount/merchants/HMXXXXXX/receive"

Solution

  • Each header field should be on a separate line so you should add a return between each key-value:

    put "ABCD" into clientId
    put "1234" into clientSecret
    
    put "Authorization: Basic" && base64Encode("clientId:clientSecret") & return & "Content-Type: application/json" & return & "Cache-Control: no-cache"  into tHeader 
    set the httpHeaders to tHeader
    
    post receiveMomoRequest to url    "https://server/v1/merchantaccount/merchants/HMXXXXXX/receive"