In azure logic App how to pass Cookie to Http request - azure

In azure logic app by calling first Http endpoint we need to get the cookie and pass to the second endpoint. But while passing second API, I am passing in header and it is sending but the response is wrong(text/html).
But When I checked by using postman it worked fine got response in JSON(application/json).
The header getting after calling second API or endpoint through logic app ,I am getting is:
{
"statusCode": 200,
"headers": {
"Cache-Control": "no-store, must-revalidate, no-cache",
"X-Powered-By": "Undertow/1",
"Set-Cookie": "JSESSIONID=Ntu9NMCoekk56JveKceina3FCwgNJptU4EK0GOIz.s192-169-141-210; path=/StLightControl",
"Server": "WildFly/10",
"Pragma": "no-cache,no-cache",
"Date": "Tue, 12 Jun 2018 14:25:45 GMT",
"Connection": "keep-alive",
"Content-Length": "2585",
"Expires": "0,0",
"Content-Type": "text/html; charset=UTF-8"
}
}

The “Add new parameter” dropdown allows you to enable a checkbox that says “Cookie” that enables you to enter the HTTP cookie (from dynamic content if you want to). You cannot enter the value straight in the dropdown, so close it down after you selected the checkbox and see a magic Cookie field appear underneath the Authentication field.
More information to be found here: HowTo: Call an API with cookie authentication from a Logic App

Related

Call SharePoint Rest API from Azure Data Factory Pipeline Web

I am trying to use Azure Data Factory to call the SharePoint Rest API to access sharepoint list data. I need to use the rest api because the SharePoint list has some complex data types (multi-select lookups).
In my pipleline I have 2 Web activities, one (called GetAToken) to get an access token and one (called GetListData) to get the data using the access token.
The GetAToken web activity does a post to https://accounts.accesscontrol.windows.net/ee780cdf-8eab-4e6f-a740-c31a2aede2c0/tokens/OAuth/2
with the body:
grant_type=client_credentials&client_id=016dfe90-1b12-4938-8a9a-dee02a43d013#ee780cdf-8eab-4e6f-a740-c31a2aede2c0&client_secret={mysecrethere}&resource=00000003-0000-0ff1-ce00-000000000000/russellwgove.sharepoint.com.sharepoint.com#ee780cdf-8eab-4e6f-a740-c31a2aede2c0
When I debug, This runs successfully and returns this object containing the token:
{
"token_type": "Bearer",
"expires_in": "86399",
"not_before": "1667487425",
"expires_on": "1667574125",
"resource": "00000003-0000-0ff1-ce00-000000000000/russellwgove.sharepoint.com.sharepoint.com#ee780cdf-8eab-4e6f-a740-c31a2aede2c0",
"access_token": "{the token is here}",
"ADFWebActivityResponseHeaders": {
"Pragma": "no-cache",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"x-ms-request-id": "32926e95-5588-42ec-a8b3-349fef942a00",
"x-ms-ests-server": "2.1.14059.10 - EUS ProdSlices",
"X-XSS-Protection": "0",
"Cache-Control": "no-store, no-cache",
"P3P": "CP="DSP CUR OTPi IND OTRi ONL FIN"",
"Set-Cookie": "fpc=AgaNWKRvGG9IkIzP4suqH9H9VI5sAQAAAO3O9doOAAAA; expires=Sat, 03-Dec-2022 15:02:05 GMT; path=/; secure; HttpOnly; SameSite=None;esctx=AQABAAAAAAD--DLA3VO7QrddgJg7Wevrrm262sBqfXG85d6ros_Ik0DCezx_KFOnktHyOEHyz8OREffRB2ad9hCwezrn2CFOzyOu5ttnkxBd1-vfkQL6eU3a6-qGSd_SaxdNREiiyLIMJIyBPp8qQU5zM1ySi6c7LVde0JFJ3jRtgH7p5QOVD4glxgUfLkK273i69DivI0G_x3wQqkpy6FLpZa2XXOjSYwZPPm1tHc_wPVBp1zd_vF3IpLLIa_pEbA_ZsTr0HscgAA; domain=.accounts.accesscontrol.windows.net; path=/; secure; HttpOnly; SameSite=None;x-ms-gateway-slice=estsfd; path=/; secure; httponly;stsservicecookie=estsfd; path=/; secure; httponly",
"Date": "Thu, 03 Nov 2022 15:02:05 GMT",
"Content-Length": "1467",
"Content-Type": "application/json; charset=utf-8",
"Expires": "-1"
},
"effectiveIntegrationRuntime": "AutoResolveIntegrationRuntime (Central US)",
"executionDuration": 0,
"durationInQueue": {
"integrationRuntimeQueue": 0
},
"billingReference": {
"activityType": "ExternalActivity",
"billableDuration": [
{
"meterType": "AzureIR",
"duration": 0.016666666666666666,
"unit": "Hours"
}
]
}
}
The GetListData activity is triggered by the OnSuccess trigger from the GetAToken Activity. It makes a GET request to https://russellwgove.sharepoint.com/sites/tr/US/_api/Web/Lists(guid'233dd303-1ae3-422b-8960-ad53661e8ef6')/Items to get the list data. It has an Authorization header set to :
#{concat('Authorization: Bearer ', activity('GetAToken').output.access_token)}
When I debug,the GetListData activity fails with an error 2108. And a message :
Error calling the endpoint 'https://russellwgove.sharepoint.com'. Response status code: 'NA - Unknown'. More details: Exception message: 'NA - Unknown [ClientSideException] The format of value 'Authorization: Bearer {myTokenhere}' is invalid.'.
Request didn't reach the server from the client. This could happen because of an underlying issue such as network connectivity, a DNS failure, a server certificate validation or a timeout.
I have no idea what that message means 'Request didn't reach the server from the client. This could happen because of an underlying issue such as network connectivity, a DNS failure, a server certificate validation or a timeout.' What is the server and the client is this context?
Anyone has any ideas how to make this work?

Logic App HTTP Trigger JSON response null value in variable

I created a logic app to get data when I trigger the logic app URI from external application. I am getting http response as expected into the logic app. As next step I am parsing JSON to get the values for specific items ("e.g. Table1") and pass into a variable. However, I get as null value into the variable
Below is the output of Logic app run where you can see the null value. Unable to find the root cause...
Http Trigger
Body:
{
"headers": {
"Connection": "close",
"Accept": "application/json",
"Accept-Encoding": "br,gzip,deflate",
"Accept-Language": "en-GB,en; q=0.9",
"Host": "prod-56.eastus2.logic.azure.com",
"Referer": "http://localhost:3000/",
"User-Agent": "Mozilla/5.0,(Macintosh; Intel Mac OS X 10_15_7),AppleWebKit/537.36,(KHTML, like Gecko),Chrome/86.0.4240.183,Safari/537.36",
"origin": "http://localhost:3000",
"sec-fetch-site": "cross-site",
"sec-fetch-mode": "cors",
"sec-fetch-dest": "empty",
"Content-Length": "125",
"Content-Type": "application/json"
},
"body": {
"studyName": "S",
"studyDescription": "DD",
"Table1": "/csdm/table1.csv",
"Table2": "/csdm/table2.csv",
"Table3": "/csdm/table3.csv"
}
}
I had the same problem. The reason was the wrong schema in the Parse JSON step. I also followed the Logic app read property of json stored in variable link. What I did was, I created a variable of the Object type called JSON_content and I placed the 'body' from the Logic App HTTP request trigger as the value. Then I added the Parse JSON action with the Content = JSON_content variable. Important thing was, that I used the input schema from the JSON_Content variable for the Parse JSON schema (using the Use sample payload to generate schema). Then the Dynamic content of the Parse JSON step consisted of JSON names (and values), which were not null finally, which I used further in the Logic App flow.

API responds with nothing when called from a Chrome extension

My issue is that I'm trying to call this API from a chrome extension:
https://wss2.cex.uk.webuy.io/v3/boxes?q=8717418549541&firstRecord=1&count=10&sortBy=relevance
Here is the code for calling the API, taken directly from Postman:
var settings = {
"async": true,
"crossDomain": true,
"url": "https://wss2.cex.uk.webuy.io/v3/boxes?q=8717418549527&firstRecord=1&count=10&sortBy=relevance",
"method": "GET",
"headers": {
"User-Agent": "PostmanRuntime/7.17.1",
"Accept": "*/*",
"Cache-Control": "no-cache",
"Postman-Token": "32322856-4e8d-4d54-87b2-199bd6181243,bea1c3bd-b5ae-4343-870d-dd73e5c88f95",
"Host": "wss2.cex.uk.webuy.io",
"Accept-Encoding": "gzip, deflate",
"Cookie": "__cfduid=dc54a227217ab713ddd4423d047c67b5f1568818173",
"Connection": "keep-alive",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Using the above code has worked perfectly fine for a long time now. However, since last Thursday, the API stopped giving any response whatsoever. Now the status code says 200 OK but the response tab says "This request has no response data available". Trying to log out the response gives nothing as well.
If you were to simply click on the above API link, the JSON should get shown since there is no authorization. My extension properly sends the API call and I can see the call being sent in the network tab of Developer tools.
Calling the API from Postman, etc... works fine.
Of course, all necessary permissions are set in the manifest and everything was working well until it just suddenly stopped. No errors or warnings, nothing.
Has this happened to anyone before? Any ideas?
Thanks in advance!

HTTP request / Service bus - application/x-www-form-urlencoded not supported error

I've got a really simple Logic app:
HTTP request (works as end-point web hook for Slack)
Send request from Slack (URI) to Service Bus queue
I haven't made any changes in Logic App but Send message action suddenly started reporting this error:
Decoding as string is not supported for content envelope of type
'application/x-www-form-urlencoded'.
Send message is defined like that:
"Send_message": {
"inputs": {
"body": {
"Label": "#{triggerBody()}"
},
...
I see only difference in request outputs:
BEFORE
Headers
{
"Accept": "*/*",
"User-Agent": "Slackbot,1.0,(+https://api.slack.com/robots)",
"Content-Type": "application/x-www-form-urlencoded"
...
}
Body
{
"$content-type": "application/x-www-form-urlencoded",
"$content": "dG9r..."
}
NOW
Headers
{
"Accept": "*/*",
"User-Agent": "Slackbot,1.0,(+https://api.slack.com/robots)",
"Content-Type": "application/x-www-form-urlencoded"
...
}
Body
{
"$content-type": "application/x-www-form-urlencoded",
"$content": "dG9r...",
"$formdata": [
{
"key": "token",
"value": "..."
},
{
"key": "team_id",
"value": "..."
},
{
"key": "trigger_word",
"value": "!"
},
...
]
}
$formdata is now a part of the output of Request as JSON array consisting of all query parameters.
Does anyone have any ideas? I would greatly appreciate any help to make it work again.
Edit: West Europe fixed and working
Yes, in the effort to have native support for x-www-form-urlencoded data in the runtime there was a bug that was recently released. We are rolling back and patching now. Can you send me an email so we can target your region for a fix, and share a workaround? Apologies in advance - as a general rule we never want to ship anything that will break existing logic apps. In this case adding some new metadata around form-data no longer allowed people to stringify x-www-form-urlencoded data (which is what you are doing here).

Azure Logic Apps Cannot send HTTP request for wns/raw notification

I have a small logic app which is meant to fetch data from somewhere and store it on blob. I then would like to send the URL to all devices via push notification. I wish to send the URL as a raw notification, so on the app/background task, i can do some processiong.
The problem is when i use logic app to create a http POST request to send a notification, i get a 400 error. The same header with authentication and etc, with the payload and URL works fine on a POSTMAN or REST API CLIENT. THe following are the inputs and outputs. Please help. Brain dead already.
This is the input.
{
"uri": "https://xxoppoc.servicebus.windows.net/xxopPOC/messages/?api-version=2015-01",
"method": "POST",
"headers": {
"Authorization": "SharedAccessSignature sr=sb%3a%2f%2fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxt%2f&sig=qEnxxxxxxxxxxxx&skn=DefaultFullSharedAccessSignature",
"Content-Type": "application/octet-stream",
"ServiceBusNotification-Format": "windows",
"ServiceBusNotification-Tags": "MyTag",
"X-WNS-Type": "wns/raw"
},
"body": "Some Raw Information. Hello World"
}
This is the output:
{
"statusCode": 400,
"headers": {
"transfer-Encoding": "chunked",
"date": "Wed, 30 Mar 2016 14:10:41 GMT",
"server": "Microsoft-HTTPAPI/2.0"
},
"body": {
"$content-type": "application/xml; charset=utf-8",
"$content": "PEVycm9yPjxDb2RlPjQwMDwvQ29kZT48RGV0YWlsPlRoZSBjb250ZW50IHR5cGUgZm9yIGEgJ3ducy9yYXcnIG5vdGlmaWNhdGlvbiBtdXN0IGJlICdhcHBsaWNhdGlvbi9vY3RldC1zdHJlYW0nLlRyYWNraW5nSWQ6NTNmNjhlMGItNDc1MC00ZDRkLWJiNTAtMzJjNTBmOGIyNDk1X0czLFRpbWVTdGFtcDozLzMwLzIwMTYgMjoxMDo0MSBQTTwvRGV0YWlsPjwvRXJyb3I+"
}
}
Let me mention again, I got the authentication correct as it works on Advanced REST Client on chrome and POSTMAN. The above logic app also works if i send a wns/toast notification with xml as its content-type. I however need it to be a wns/raw notification. Please help. Thank you
EDIT/PROGRESS
Thanks to MichaelB, We figured out that the content-type is being modified. I sent the request to a different URL to look at the header. The following was observed:
Content-Type: application/octet-stream; charset=utf-8
If I use the above Content-Type on POSTMAN. It actually fails as well. So this could be 1 step. Why is Azure Logic Apps adding charset-utf-8 to the end of my content type. Can I stop it?

Resources