簡體   English   中英

如何將表單數據發送到 API - Windev 24

[英]How to send form data to an API - Windev 24

我正在嘗試在 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(如果向請求添加了 falses 參數,我會收到我創建的錯誤消息),但是由於我找不到加入所需參數的正確方法,所以我停止了。

我試圖閱讀文檔並試圖自己弄清楚,但我找不到這樣做的方法。

請問這里有人可以幫我嗎?

先感謝您

這很簡單,你必須使用到specifiy要發送到服務器的內容類型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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM