我使用的是德爾福REST.Client成分,並要送這樣的請求:TRESTRequest:如何查詢字符串參數添加到PUT請求
PUT http://hostname/api/items?arg=value
下面是我使用的代碼:
req := TRESTRequest.Create(nil);
req.Client := FRESTClient;
req.Method := TRESTRequestMethod.rmPUT;
req.Resource := 'api/items';
req.AddParameter('arg', 'value');
req.AddBody(someJSONObject);
req.Execute;
但是,Fiddler表示參數是而不是被包含在請求中,並且服務器拒絕格式嚴重的請求。
PUT http://hostname/api/items HTTP/1.1
Content-Type: application/json
Content-Length: 123
Connection: keep-alive
Host: hostname
Accept: application/json, text/plain; q=0.9, text/html;q=0.8,
Accept-Charset: UTF-8, *;q=0.8
Accept-Encoding: identity
User-Agent: Embarcadero RESTClient/1.0
在Delphi調試器,我可以看到,所使用的是parameter kindpkGETorPOST
(缺省值)。我沒有看到Kind的任何價值,看起來他們會解決這個問題。
任何想法我做錯了什麼?許多這些類別的文檔是notveryhelpful。
您是否嘗試過簡單地將參數追加到資源屬性,比如'api/items?arg = value'? – mjn 2014-11-02 10:00:14