我正在尝试通过 REST 界面更新 Prestashop 中的制造商。到目前为止,我已经能够获取信息,但是当我尝试 PUT 时,我总是收到 HTTP 500 错误。
try
Memo1.Text := '<prestashop><manufacturer><id><![CDATA[804]]></id><name><![CDATA[DisneyLand]]></name></manufacturer></prestashop>';
RESTRequest1.Params.Clear;
//authentication does not work with PUT, use token as suffix....
RESTClient1.Authenticator := nil; //SimpleAuthenticator1;//
//SimpleAuthenticator1.UserNameKey := 'ws_key';
//SimpleAuthenticator1.UserName := 'HEREIGOESTHETOKEN';
RESTRequest1.Resource := 'manufacturers';
RESTRequest1.ResourceSuffix := '?ws_key=HEREIGOESTHETOKEN';
RESTRequest1.Method := rmPut; //update
RESTClient1.BaseURL := 'http://localhost/prestashop/api';
RESTRequest1.Params.AddItem('id', '804' ,pkGETorPOST , [], ctTEXT_PLAIN);
RESTRequest1.Params.AddItem('putXml', Memo1.Text,
pkGETorPOST , [], ctAPPLICATION_X_WWW_FORM_URLENCODED);
RESTRequest1.Execute;
Memo1.Lines.Clear;
Memo1.Lines.Add(RESTResponse1.Content);
except
on E : Exception do
begin
Memo1.Lines.Clear;
Memo1.Lines.Add('Exception class name = '+E.ClassName);
Memo1.Lines.Add('Exception message = '+E.Message);
end;
end;
我尝试了其他 TRESTRequestParameterKind 可能性,但无济于事。
以前有人试过吗?