简体   繁体   English

Paypal发布到C#REST API端点

[英]Paypal post to C# REST API endpoint

In my front end, I have this piece of code that should call the API post endpoint: 在我的前端,我有这段代码应该调用API post端点:

... 
onAuthorize(_data: any, actions: any) {
actions.request.post('https://localhost:44353/api/payment',_data)
    .then...

API endpoint looks like this API端点如下所示

[ProducesResponseType(201)]
[HttpPost("payment")]
public async Task<IActionResult> Payment([FromBody] PaypalDTO paypal){...

But the API call returns: bad request/bad format.. 但是API调用返回:错误的请求/错误的格式。

Currently the only way to pass data that I found is through query params.. 目前,传递我发现的数据的唯一方法是通过查询参数。

But I bet there is a way to format the REST API Endpoint to get the _data object. 但是我敢打赌,有一种方法可以格式化REST API端点以获取_data对象。

Ideas? 有想法吗?

Firstly, can you control your json data ? 首先,您可以控制json数据吗? And secondly can you add Content-Type your request ? 其次,您可以添加Content-Type您的请求吗?

Finally maybe this link helps to you 最后,也许此链接对您有所帮助

Official Microsoft tutorial 微软官方教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM