如何将表单数据发送到API-Windev 24

马可·福格勒

我正在尝试在Windev24上构建一个简单的应用程序,但是我找不到正确的代码来使用post方法将数据发送到使用Lumen框架构建的API中。如果我通过Postman测试API,则一切正常。这是邮递员窗口的屏幕截图:屏幕截图

我尝试了这段代码:

//MaReq est un restRequête
LaRéponse est un restRéponse

MaReq.URL="https://mywonderfulapi.ch/record"

//I need to find the way to join parameters here...

MaReq.Méthode=httpPost
LaRéponse=RESTEnvoie(MaReq)

SI ErreurDétectée ALORS
    Erreur(HErreurInfo(hErrComplet))
SINON
    info(LaRéponse.Contenu)
    Info(UTF8VersChaîne(LaRéponse.Contenu))
        rep = JSONVersVariant(LaRéponse.Contenu)
        info(rep)   
FIN

我可以正确连接到API(如果将错误参数添加到请求中,我会收到创建的错误消息),但是由于找不到适合所需参数的正确方法,我停了下来。

我试图阅读文档,并试图自己找出来,但我找不到解决方法。

请问有人可以帮助我吗?

先感谢您

亚瑟罗斯

您必须使用来指定要发送到服务器的内容的类型,这很简单MaReq.ContentType = {YourContentType},然后使用来指定内容MaReq.content = {YourContent},因此您的代码应如下所示:

//MaReq est un restRequête
LaRéponse est un restRéponse

MaReq.URL="https://mywonderfulapi.ch/record"
MaReq.ContentType = //yourContentType
MaReq.Content = // YourContent

MaReq.Méthode=httpPost
LaRéponse=RESTEnvoie(MaReq)

SI ErreurDétectée ALORS
    Erreur(HErreurInfo(hErrComplet))
SINON
    info(LaRéponse.Contenu)
    Info(UTF8VersChaîne(LaRéponse.Contenu))
        rep = JSONVersVariant(LaRéponse.Contenu)
        info(rep)   
FIN

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章