我正在使用 SBCL、Emacs、Slime 和 Dexador。我也在 Udemy 上觀看有關
POST 請求是在 address 發出的https://simple-tool-rental-api.glitch.me/api-clients。此外,還提交了一條訊息作為 JSON 格式的正文:
{
"clientName": "Postman",
"clientEmail": "[email protected]"
}
作為回復,服務器回復:
{
"accessToken": "079e7bb6d3832c0d7054ae0e1146d6ed3277836fefd2e0aa9e5d7d207945e17f"
}
我嘗試使用名為Dexador的著名庫并使用檔案說明來做同樣的事情:
CL-USER>(dex:post "https://simple-tool-rental-api.glitch.me/api-clients"
:content '(("clientName" . "Postman") ("clientEmail" . "[email protected]")))
不幸的是,Slime 回傳一條錯誤訊息,指示 400 錯誤請求:
An HTTP request to "https://simple-tool-rental-api.glitch.me/api-clients" returned 400 bad request.
{"error":"Invalid or missing client name."}
這是一個錯誤嗎?我錯過了什么?
uj5u.com熱心網友回復:
一個作業示例:
(dex:request "https://simple-tool-rental-api.glitch.me/api-clients"
:method :post
:headers '(("Content-Type" . "application/json"))
:content "{\"clientName\":\"Postman\",
\"clientEmail\": \"[email protected]\"}"
:verbose t)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
POST /api-clients HTTP/1.1
User-Agent: Dexador/0.9.15 (SBCL 1.4.5.debian); Linux; 5.0.0-31-generic
Host: simple-tool-rental-api.glitch.me
Accept: */*
Content-Type: application/json
Content-Length: 83
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
HTTP/1.1 201 Created
Date: Tue, 05 Apr 2022 12:44:55 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 82
Connection: keep-alive
x-powered-by: Express
etag: W/"52-egRRCktqEOIEh9dS2uY8rWUiyfY"
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"{\"accessToken\":\"7e559ebee8ff889054346dbbd727c1bb9b9d55123fb5bd49686337e8829f8b78\"}"
201
#<HASH-TABLE :TEST EQUAL :COUNT 6 {1003C05373}>
#<QURI.URI.HTTP:URI-HTTPS https://simple-tool-rental-api.glitch.me/api-clients>
#<CL SSL::SSL-STREAM for #<FD-STREAM for "socket 192.168.1.53:39148, peer: 18.205.205.44:443" {10035F4C33}>>
我使用“pete”電子郵件,因為 pedro one “已經注冊”。我使用手動格式化的 JSON 來發送帶有Content-Typeof的憑證application/json,我確信這種格式。我想使用 Postman 螢屏截圖中的“原始”內容型別,但不確定 alist 是否能很好地使用它。
我認為通過更好地了解示例 API,您可以整理出另一種與 alist 正文內容一起使用的內容型別。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/456373.html
