Answered by:
Invoke Web Job with credentials on HTTP Post Action in Logic App Fails with 401 Unauthorized

Question
-
I'm trying to invoke a triggered web job in Azure from a Logic App. I am using the HTTP action posting the following URL:
Method:
POSTUri:
https://$slicetime:AAMYKEYAA@slicetime.scm.azurewebsites.net/api/triggeredwebjobs/FullSync/run?arguments%3D-x+-nNo Headers, No Body.
The Outputs are
- Status code
401
- Headers
{ "Date": "Mon, 31 Oct 2016 06:07:31 GMT", "Server": "Microsoft-IIS/8.0", "WWW-Authenticate": "Basic realm=\"site\"", "Content-Length": "1293", "Content-Type": "text/html" }
- Body
...<title>401 - Unauthorized: Access is denied due to invalid credentials.</title> <
-
...<h1>Server Error</h1>
-
...<h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
-
... <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
The HTTP post works fine with curl and Postman. Any ideas?
Thanks
Barry Gervin
Barry Gervin
Monday, October 31, 2016 6:46 AM - Status code
Answers
-
Hi Barry,
Seems like cURL uses the syntax
http://myusername:mypassword@somesite.com
Based on your URL, you can you try the following on the HTTP action:
URL: https://slicetime.scm.azurewebsites.net/api/triggeredwebjobs/FullSync/run?arguments%3D-x+-n
Method: POST
Headers:
{ “Authorization”:”Basic @base64(‘$slicetime:AAMYKEYAA’)” }
This might do the trick.
I hope this helps, Wagner.
- Edited by WSilveiraNZ [MVP]MVP Monday, October 31, 2016 9:33 AM
- Proposed as answer by WSilveiraNZ [MVP]MVP Thursday, November 3, 2016 12:51 AM
- Marked as answer by Sjoukje ZaalMVP Tuesday, August 1, 2017 12:57 PM
Monday, October 31, 2016 9:32 AM
All replies
-
Hi Barry,
Seems like cURL uses the syntax
http://myusername:mypassword@somesite.com
Based on your URL, you can you try the following on the HTTP action:
URL: https://slicetime.scm.azurewebsites.net/api/triggeredwebjobs/FullSync/run?arguments%3D-x+-n
Method: POST
Headers:
{ “Authorization”:”Basic @base64(‘$slicetime:AAMYKEYAA’)” }
This might do the trick.
I hope this helps, Wagner.
- Edited by WSilveiraNZ [MVP]MVP Monday, October 31, 2016 9:33 AM
- Proposed as answer by WSilveiraNZ [MVP]MVP Thursday, November 3, 2016 12:51 AM
- Marked as answer by Sjoukje ZaalMVP Tuesday, August 1, 2017 12:57 PM
Monday, October 31, 2016 9:32 AM -
Thank you Wagner,
I wasn't able to get the @base64 function to work. Same error message, but you got me pointed in the right direction. I manually encoded by userid & password (with the $) and then just used that in the header. I also in my attempts ended up with a content type. This solution works.
{ "Authorization": "Basic mybase64useridandkeyendingwith=", "Content-Type": "application/json" }
Barry Gervin
Wednesday, November 2, 2016 12:34 PM -
Great to know mate.
Here is how I created the Authorization on my case:
{ "Authorization": "Basic @{base64(parameters('$mycredentials'))}", "Content-Type": "application/json" }
Then my $mycredentials parameter looks like this:
"parameters": { "$connections": { "defaultValue": {}, "type": "Object" }, "$mycredentials": { "defaultValue": "username:password", "type": "String" } }
I hope this helps, Wagner.
Thursday, November 3, 2016 1:06 AM