Hola a todos,
tengo un problema al integrar datos de mi aplicación con el modulo web de Prestashop mediante TIdHTTP, puedo pedir una ficha y actualizarla, pero no he conseguido crear una nueva. ¿ Alguien me puede asesorar al respecto ?
El código que utilizo ahora es el siguiente:
Código Delphi
[-]
var
strXml: string;
ListValues := TStringList;
Response: TMemoryStream;
TheXML: IDOMDocument;
ChildNode: IDOMNode;
XMLRequest: TStringStream;
begin
strXml := IdHTTP1.Get ('http://mitienda/api/customers?schema=blank');
XMLDocument1.LoadFromXML(strXml);
XMLDocument1.Active := True;
IDomSel := (XMLDocument1.DocumentElement.DOMNode as IDOMNodeSelect);
TheXML := XMLDocument1.DOMDocument;
Node := IDomSel.selectNode('customer/id');
ChildNode := Node.AppendChild(TheXML.createCDATASection('id'));
ChildNode.NodeValue := sNuevoID;
Node := IDomSel.selectNode('customer/firstname');
ChildNode := Node.AppendChild(TheXML.createCDATASection('firstname'));
ChildNode.NodeValue := sFirstName;
Node := IDomSel.selectNode('customer/lastname');
ChildNode := Node.AppendChild(TheXML.createCDATASection('lastname'));
ChildNode.NodeValue := sLastName;
XMLDocument1.SaveToXML(strXml);
ListValues := TStringList.Create; Response := TMemoryStream.Create;
IdHTTP1.Request.ContentType := 'text/xml';
IdHTTP1.Post('http://mitienda/api/customers/?xml=' + strXml, ListValues, Response);
Response.Free;
ListValues.Free;
end;
Gracias de antemano