可以从逻辑应用到ASP.NET Core Web API执行HTTP Post Post Post Paction
我已经构建了许多逻辑应用程序。我还与Logic App API集成了。由于某种原因,向ASP.NET Core Web API的邮政请求无法正常工作。它在Postman中起作用,但我无法获得逻辑应用程序来完成请求。
该请求到达我的Web API。我可以在远程调试会话中逐步完成它。我在API方法上使用了[从体体]装饰器。对象中的所有字符串值都是null。
程序标头
accept =“ application/json”
contentType =“ application/json”
contentlength =“ 35”
host =“ ****。centralus.logic.azure.com”
逻辑应用
[HttpPost]
[Route("CreateSomething")]
public async Task<IActionResult> CreateSomething([FromBody] MyObject object)
{
//Create something great
}
我认为这可能与标题有关。我注意到,除非我在“标题”部分中检查主机和内容长度框,否则邮递员请求将不会成功。根据本文,逻辑应用程序忽略了这些标题。
https://learn.microsoft.com/en-en-us/ Azure/Connectors/Connectors-native-HTTP
我已经使用API构建了HTTP POST操作,并使用Azure中的逻辑应用UI手动配置了它。
顺便说一句,有人知道会自动计算contentLength的表达式吗?
更新:
我终于弄清楚了。我不得不做一些忍者编码垃圾来完成这项工作。我明天发布解决方案。
有人知道如何做这项工作吗?提前致谢!
I've built many Logic Apps. I've also integrated with the Logic App API. For some reason, a Post request to an Asp.net Core Web API won't work. It works in Postman, but I can't get Logic Apps to complete the request.
The request arrives at my Web API. I can step through it during a remote debug session. I'm using the [FromBody] decorator on the API method. All the string values in the object are null.
Logic App Headers
Accept = "application/json"
ContentType = "application/json"
ContentLength = "35"
Host = "****.centralus.logic.azure.com"
API method
[HttpPost]
[Route("CreateSomething")]
public async Task<IActionResult> CreateSomething([FromBody] MyObject object)
{
//Create something great
}
I think it might have something to do with the Headers. I noticed that the Postman request won't succeed unless I check the Host and Content-Length box in the Headers section. According to this article, Logic Apps ignores those Headers.
https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http
I've built the HTTP Post Action using the API as well as configured it manually using the Logic App UI in Azure.
By the way, does anyone know the Expression that will automatically calculate the ContentLength?
UPDATE:
I finally figured this out. I had to do some Ninja coding crap to make this work. I'll post my solution tomorrow.
Does anyone know how to make this work? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用逻辑应用程序API编程创建逻辑应用程序时,您必须指定何时执行HTTP Post的操作。当车身JSON显示在设计器中时,它包含一个带有对象属性的对象。我的API方法无法处理。关键是简单地将属性发布在JSON体内。更糟糕的是,我在此特定逻辑应用程序中执行了两个HTTP帖子。当我尝试将我的对象属性添加到现有的身体类中时,这会导致我的其他HTTP帖子停止工作。为了克服这一点,我必须使用对象属性创建一个Body2类。然后,在将JSON添加到Logic App API调用中之前,我不得不使用以下代码将Body2替换为Body2。
这无效。
这起作用了。
请注意,我在Body2上使用了替换。
When you use the Logic App API to programmatically create Logic Apps, you have to specify the Body class for when you do something like an HTTP Post. When the Body JSON displayed in the designer, it contained a single object with the objects properties. My API method could not handle this. The key was to simply post the properties in the JSON Body. To make matters worse, I'm doing two HTTP Posts in this particular Logic App. When I tried to add my object properties to the existing Body class, it caused my other HTTP Post to stop working. To overcome this, I had to create a Body2 class with the objects properties. I then had to use the following line of code to replace body2 with body before adding the JSON to the Logic App API call.
This did not work.
This worked.
Notice I used Replace on body2.