Skip to main content

Notifications

Power Automate - Connector Development
Unanswered

HTTP command not performing as expected - compared with curl

(0) ShareShare
ReportReport
Posted on by 28

 I have the following curl command:  (changed some of the id chars at the end)

curl --location 'http://openapi.tuyaeu.com/v1.0/devices/bf83fd230c6a16d19fv0xx/commands' \
--header 'client_id: 5yucsmrw8rtmkpxh5mxx' \
--header 'access_token: 0b81227ee0cff5c53343d15983dced4f' \
--header 'sign: 22CA58C6D6FD0EF69C475EC382A71AA90C29772052D70981C682C64315372F22' \
--header 't: 1712667883918' \
--header 'sign_method: HMAC-SHA256' \
--header 'Content-Type: application/json' \
--data '{
"commands":[
{
"code": "switch_1",
"value":true
}
]
}'

 

 

 

I built this into HTTP:

 

Rookie1_0-1712727437083.png

 

cURL give me expected response while HTTP says sign invalid.

 

 

I checked about 100 times and think I have all the lettering correct.

I executed curl command and also tested this with Postman - all working, except HTTP.

 

Is there anyway that I can debug and see what HTTP is actually requesting to help me debug?

 

 

  • Rookie1 Profile Picture
    Rookie1 28 on at
    Re: HTTP command not performing as expected - compared with curl

    I found this as a solution to my problem :

    https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-call-a-custom-connector-from-powerapp-passing-raw-body-as/td-p/169820. This works great. I just wich I could do this from powerautomate.

  • Rookie1 Profile Picture
    Rookie1 28 on at
    Re: HTTP command not performing as expected - compared with curl

    Thanks for the answer. I have a large part already as custom code, but working with Postman, I tried to bypass some c# matrix code where the coding is done and just pass the result. I copied and pasted the code and let postman do the calculation (it is the same for all and I end up with a string for on and a string for off) No matter what I do, the payload remains 89 characters in postman, which means they strip everything off when doing the call.

     

    I guess my outcome should be to do more coding in c#, just not sure if that will give the correct result. Bottom line is when I switch custom connector to raw mode and paste in the body from postman, it works and shows as 89 characters. Maybe I should design body as empty and send a raw string from powerapps/powerautomate?

     

    I am a bit stumped at this stage. 

  • choongseng Profile Picture
    choongseng 2 on at
    Re: HTTP command not performing as expected - compared with curl

    I'm not sure if you intend to have the calculation of the signature hash (your sign) done by the caller or to be in your custom connector. I think if it is supposed to be calculated by the custom connector, then you could make use of the custom code section to write some code to recalculate that and replace your request header.

     

    Check this page for the custom code support in custom connector:

    https://learn.microsoft.com/en-us/connectors/custom-connectors/write-code

     

  • Rookie1 Profile Picture
    Rookie1 28 on at
    Re: HTTP command not performing as expected - compared with curl

    I found the problem, but does not have the solution. The problem is that the sign is calculated from many of the contents of the total query,

    The body is critical. In the curl it is built from tabs to create the json and in powerapps spaces are used.  This makes the curl string 89 characters vs 109 characters in powerapps. Therefore signature fails.

     

    I tried to compress the json string in both cases without any spaces or tabs, but the spaces are automatically inserted when I publish the HTTP flow.

     

    Interesting problem, but I do not have a solution. I will appreciate any idea.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,526

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard

Featured topics