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?
Related
I have an azure function which works well when I call it from postman . I am trying to invoke the same from logic app as when an HTTP request is received. However, I am unable to pass raw content in the APIM as it does not give me an option for the same. It let me add only the subscription key.
My Azure APIM accepts file name, subscription key only.
Any help in this regard is much appreciated.
Postman : (I have added Headers - Content-Type, Accept: using )
Headers:
Content-Type :
Accept:
Ocp-Apim-Subscription-Key
Body:
{
"name": "olaf"
}
Azure Logic App: (Using Peek Code);
{
"inputs": {
"method": "post",
"headers": {
"Accept": "application/json",
"Content-Type": "text/csv"
},
"pathTemplate": {
"template": "/scg-liquidTransformer-functionApp/liquidtransformer/{liquidtransformfilename}",
"parameters": {
"liquidtransformfilename": "#{encodeURIComponent('xmlsample.liquid')}"
}
},
"api": {
"id": "/subscriptions/XXXXXXXXXXXXXXXXXXXXX/resourceGroups/scg-mel-dev-arg-liquidtransformer/providers/Microsoft.ApiManagement/service/scg-liquidTransformer-functionApp-apimservice/apis/scg-liquidtransformer-functionapp"
},
"subscriptionKey": "XXXXXXXXXXXXXXXXXXXXXXXX"
}
}
I need to send body {} as a parameter input in the azure functionenter image description here.
Thanks,
Paul.
enter image description here
You need to do configuration in your APIM, please refer to the steps below:
1. Go to your APIM, find your api and click the "pencil" icon.
2. In next page, click "Request" tab and click "Add representation" to add "application/json".
3. Then click "New definition"
4. Input the json sample of request body, it will generate the schema automatically in "Payload" box.
5. Click "Save", then go back to your logic app and add the APIM api. You can find there is a field "name" for you to choose.
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!
I am getting Http 500 error whenever i am calling the QnAMaker Api with Metadata(strictFilter) body. Am I not following any instruction before calling Apis?
QnA maker api is working perfectly if I am not adding strictFilter in the Api request body.
api request details:
URL: https://qnamaker endpoint/qnamaker/knowledgebases/KBID/generateAnswer
Method: POST
content-type: application/json
Authorization: EndpointKey Key
Body:
{
"question": "hi",
"top": 3,
"strictFilters": [
{
"name": "category",
"value": "pears"
}
]
}
I have even read the Microsoft documentation
Still no luck for me here.
QnaMaker Response Error with StrictFilter screenshot
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
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).