Logic App使用JSON发送消息错误 [英] Logic App Send Message error with JSON

查看:90
本文介绍了Logic App使用JSON发送消息错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Logic App将消息发送到Azure上的服务总线.逻辑应用程序以触发器的HTTP请求开头,该请求的主体中包含JSON负载.请求的正文"设置为发送消息"操作的内容.由于发布时有效负载为JSON,因此我将Content-Type设置为application/json.这会在发送消息"操作上生成错误;

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;

{代码":"InvalidTemplate",消息":在操作'Send_message'中无法处理模板语言表达式.输入"1"行和"1221"列:模板语言函数"encodeBase64"期望其参数为字符串.提供的值是对象"类型.请参见

{"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.'."}

因此尝试将Content-Type更改为text/plain并起作用吗?这是一个错误,还是应该在发送消息"操作中使用JSON之前将其转换为文本值?

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?

推荐答案

将消息发送到服务总线需要消息内容经过base64编码.由于您的内容是JSON,因此您需要在编码之前明确对其进行字符串化处理,即使用@encodeBase64(string(jsonContent))

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.

这篇关于Logic App使用JSON发送消息错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆