Tema: Prestashop
Ver Mensaje Individual
  #1  
Antiguo 05-04-2013
JosepGA JosepGA is offline
Miembro
 
Registrado: jun 2007
Ubicación: Tarragona
Posts: 166
Reputación: 17
JosepGA Va por buen camino
Prestashop

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; // para poder utilizar metodo POST
  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
Responder Con Cita