Logic App Send Message error with JSON - azure

I'm using Logic App to send a message to a service bus on Azure. The logic app starts with a HTTP Request for the trigger which contains a JSON payload in the body. The 'Body' of the request is set as the Content of the Send Message action. Since the payload is JSON when posting I set the Content-Type to application/json. This generates an error on the Send Message action;
{"code":"InvalidTemplate","message":"Unable to process template language expressions in action 'Send_message.' inputs at line '1' and column '1221': 'The template language function 'encodeBase64' expects its parameter to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#encodeBase64 for usage details.'."}
So tried changing the Content-Type to text/plain and it works? Is this a bug or should convert the JSON to a text value somehow before using it in the Send Message action?

Sending a message to service bus requires the message content to be base64 encoded. Since your content is a JSON, you would need to stringify it explicitly prior to encoding, i.e. use #encodeBase64(string(jsonContent))
Changing the content type to text/plain has the same effect, since in that case the content is treated as a string to begin with.

Related

How to send query parameters and body data in jMeter post request

I am new to Jmeter please help me in this, i try to do performance test of my nodejs application.And i have one api, for this i have to pass parameters as well as post from .csv file but i am not able to achieve so give your valuable input
Put your parameters to "Path" input field
Put your request body to "Body Data" input field
You might also need to add a HTTP Header Manager and configure it to send Content-Type header with the value of application/json. See REST API Testing - How to Do it Right for more details.

How to Use HTTP Receive GET Message in Orchestration?

I have set up a HTTP Receive (req-response) adapter and the message appears to be getting to the message box. When I create an orchestration using a direct bound logical port, I am getting the message but everything I have tried to read the message body has failed (using passthrough pipeline, XML pipeline with allow unrecognized files = true) but I get exceptions any time I try to use the incoming message (message assignments, sending the message to a custom module to try to read the part(s)).
Rather than go into details on exceptions, can anyone point to instructions on what the proper way to access/use the body of the HTTP Get messages within an orchestration? To explain what I am trying to do, I want to take the query string (body) and send it verbatim to another orchestration for processing, so I simply want to extract the body (query string) from the message.
For a GET request without a body you need to use the WCF-WebHttp adapter rather than the deprecated BTSHTTPReceive.dll
With the WCF-WebHttp you can use the Variable Mapping to populate message context properties with the URI parameters.
So the answer was to NOT use the HTTP adapter for GET requests. I did not realize the HTTP adapter has effectively been deprecated. For basic GET requests I had to switch to the WCF-WebHTTP adapter and make sure to include the property in the property schema and then make sure to set the schema in the variable mapping as the property schema, not the message type schema of the incoming message. I wish the Microsoft documentation was more clear that the HTTP adapter cannot be used for very basic GET requests in which a body is not provided in the request.

azure logic app & http step response

I have 2 HTTP actions, one after another in a logic app, how do I read the response from a previous HTTP action in the second HTTP action?
First HTTP call (REST) returns a response in JSON format -
{
"authResult": {
"isPasswordExpired": true,
"authToken": "cxxcxcxc",
"message": "Login Successful"
}
}
I want to send authtoken from the result in second http action as authorization header.
As Derke Li mentioned that we could use exression or Parse Json to do that. I also do a demo about how to use the Parse JSON action.
1.Add the Parse Json action after the first Http action
2.Add the parse content and click on the button "Use sample payload to generate schema" and that will pop a new window. Paste in your "authResult" json. As seen in the below image.
3.Then we could pick the token from the dynamic content.
4.We could check the result.
There are two ways you can do this.
Use expression to directly reference the property. #body('NameOfFirstHTTPAction')?['authResult']?'[authToken]
Add a "Parse JSON" action in between the two HTTP action, and provide a sample response of the first HTTP action to generate a schema. Then, in the second HTTP action, you will see authToken as a token from the dynamic content picker for you to reference.

Jain-Sip dialog message body

I have an app using JAIN-SIP. The application will send SIP NOTIFY messages with event type dialog and content-type application/dialog-info+xml.
Is there an API for building the (xml) message body. The javax.sip.message.MessageFactory takes a java.lang.Object for the message body, since the type can vary depending on the request. But are there any libraries to facilitate constructing the format of the body?

Calling multipart/form-data REST service in Azure Logic Apps

I have made a workflow using Http Listener and Http actions in Azure Logic Apps. Listener is to catch POST request and Http action has details of my api which is hosted over azure web app. Request is multipart/form-data type and posts a file along with 3 other string values.
My problems are
If I'm explicitly setting content type header as multipart/form-data in Http action, it is not passing any boundary to api controller and my api is giving error "request was rejected because no multipart boundary was found".
If I'm trying to pass #triggers().outputs.body.ContentType as header of my http action, I'm getting this error:
{"code":"InvalidTemplate","message":"Unable to process template
language expressions in action 'http' inputs at line '1' and column
'11': 'Error converting value \"multipart/form-data;
boundary=----WebKitFormBoundaryi3knGy6dh92BdKdr\" to type
'Microsoft.WindowsAzure.ResourceStack.Common.Collections.InsensitiveDictionary`1[System.String]'.
Path 'headers'.'."}
Please help, how can I pass content type and boundary both to my api using Http action?
The headers object in the Logic app definition is a JSON object with keys and values. Specifically, if you want to pass the content-type header like above your object definition in the code view would look like:
"MyAction" : {
"type" : "http",
"inputs" : {
"headers" : {
"Content-type" : "#triggerBody().ContentType"
},
"body" : … rest of properties here …
Hopefully this is why your API isn't getting the boundary either.

Resources