簡體   English   中英

通過 HTTP API restful-url 自動發布 XML 有效負載

[英]Automating Posting of XML payload via HTTP API restful-url

我是 API 集成的新手,目前使用 Postman UI 手動將 XML 有效負載主體發布到供應商 ZDB974238714CAACEDE4FZ 網絡服務。 這很好用,但是我需要找到一個解決方案來自動化這個過程。

The idea is that our app will generate an XML output file to a directory and an scheduled script or app read/ wrap the contents of the XML into the body of a HTTP API POST. 處理完 XML 文件后,需要將其移至存檔文件夾以進行審核。

理想情況下,腳本或應用程序將能夠將此 POST 響應寫入文本文件(用於審計目的)。

誰能推薦任何 PowerShell 腳本模板或替代方法,無需廣泛的編碼知識即可自動執行此過程?

環境為 Windows。

謝謝

Postman為API的發展創造了完善的生態系統。 它允許您手動玩弄 API、自動化、監控、模擬等。

您的用例不需要單獨的工具,您可以創建一個集合並將請求正文作為變量傳遞

將請求正文設置為:

{{testBody}}

在此處輸入圖像描述

現在將集合導出為 json 並使用來自 powershell 的 newman 運行它

 $xmlFile = Get-Content .\test.xml
 $a = "run .\canvasjs.postman_collection.json  --env-var=`"testBody=$xmlFile`" -r htmlextra"
 Start-Process "C:\Users\AppData\Roaming\npm\newman" -args $a

暫無
暫無

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

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