0

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

我试过这段代码:

//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(如果错误参数被添加到请求中,我会收到我创建的错误消息),但是由于我找不到加入所需参数的正确方法,所以我停了下来。

我试图阅读文档并试图自己弄清楚,但我找不到这样做的方法。

请问这里有人可以帮我吗?

先感谢您

4

1 回答 1

1

这很简单,您必须通过 using 指定要发送到服务器的内容类型MaReq.ContentType = {YourContentType},然后通过 using 指定内容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
于 2020-10-01T07:05:01.217 回答