Cannot post multiple objects with XML to /thirdparties in API

Hi!

I am developing an integration to Dolibarr with Java where the integration is suppose to handle posting mulitple leads from one file to the module thirdparties in Dolibarr. The post is managed through Dolibarr API. This is my code in Java with the XML data:

data = "<?xml version=\"1.0\"?><leads>";

			for(int i = 0; i < leadList.size(); i++) {
				//OutputStreamWriter writer = new OutputStreamWriter(httpc.getOutputStream());
				//BufferedWriter bw = new BufferedWriter(writer);
				data += "<lead>"					
					+ "<name>" + leadList.get(i).getCompany() + "</name>" 
					+ "<name_alias>" + leadList.get(i).getContact() + "</name_alias>" 
					+ "<address>" + leadList.get(i).getAddress() + "</address>" 
					+ "<zip>" + leadList.get(i).getZipCode() + "</zip>"
					+ "<town>" + leadList.get(i).getCity() + "</town>"
					+ "<email>" + leadList.get(i).getEmail() + "</email>"
					+ "<phone>" + leadList.get(i).getPhoneNumber() + "</phone>"
					+ "<idprof1>" + leadList.get(i).getCurrentProvider() + "</idprof1>"
				 	+ "<idprof2>" + leadList.get(i).getSize() + "</idprof2>"
				 	+ "</lead>";				
			}
			
			data += "</leads>";

It is working when posting only one object, but when I try to post multiple objects within a for-loop the API responds with a 400 statuscode and a message saying that “name field missing”. I have used the API explorer to see how the XML is supposed to be formed when posted to the endpoint but it still returns status 400:

{
    "error": {
        "code": 400,
        "message": "Bad Request: name field missing"
    },
    "debug": {
        "source": "api_thirdparties.class.php:1827 at call stage",
        "stages": {
            "success": [
                "get",
                "route",
                "negotiate",
                "authenticate",
                "validate"
            ],
            "failure": [
                "call",
                "message"
            ]
        }
    }
}

If anyone is available to help me with this, I would highly appreciate! Please let me know and I will provide with further information :slight_smile:

Best regards