Forum Discussion

fidoslav's avatar
fidoslav
Copper Contributor
Feb 22, 2022

Action.Http in Outlook Adaptive Cards and Authorization header

Hello,

I am testing Adaptive Cards in Emails and I have problem with Action.Http. I am using it for communication with ERP. The ERP requires REST endpoint with authorization. So I created header with this "Authorization" = "Basic base64auth". Problem is that Action.Http return error 401 unathorized. I tested it with Postman or PowerShell and everything works perfectly.

 

                            $Uri = "my endpointurl"
                            $ApiHeader = @{}
                            $ApiHeader += @{"Authorization" = "Basic base64auth"; }
                            $ApiHeader += @{"Accept-Language" = "en-US"; }
                            $ApiHeader += @{"Accept" = "application/json"; }
                            $ApiHeader += @{"Content-Type" = "application/json; charset=utf-8"; }
                            $ApiHeader += @{"Isolation" = "snapshot"; }
                            $ApiHeader += @{"If-Match" = "*"; }
                            $RequestBody = '{'
                            $RequestBody += '"externalDocumentNo": "' + 'Test' + """"
                            $RequestBody += '}'
                            $ResponseContent = Invoke-RestMethod -Uri $Uri -Method PATCH -Headers $ApiHeader -Body $RequestBody -ContentType "application/json; charset=utf-8" -UseBasicParsing -ErrorAction Stop

 

Can you help me. Do you use different authorization for action? How can I use basic authorization?

 

Thank you for your help

 

 

Resources