Azure API App proxy generation error

守給你的承諾、 提交于 2019-12-11 10:41:08

问题


I was able to successfully create a test API and host in Azure. However when I try to create the proxy client, I receive the following error.

[Fatal]Error generating service model: The operation 'Get' has a body parameter, but did not have a supported MIME type ('application/json') in its Consumes property.
Exception: There was an error during code generation when trying to add a client for the Microsoft Azure API App
Generating client code and adding to project failed

I checked the Swagger file and the Contains node was empty. When I change it to

"consumes": [ "application/json", "application/xml" ]

the proxy creation works. Why did the auto-generated Swagger json not have the Contains property set? I went with the default SwaggerConfig when I created the API app. Am I missing some configuration? Any help will be greatly appreciated.


回答1:


As I found out from the comments, the solution is to to remove the HttpRequestMessage as parameter of the Action. This will enable the API App Client to generate the code OK.

If you need to mock the object, please follow the documented way from here or another example here.



来源:https://stackoverflow.com/questions/29316677/azure-api-app-proxy-generation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!