0

I am getting very frustrated. I am using .NET to import a bunch of leads in to vTiger 6.2.0. I am using a simple web request that i have seen plenty of examples working. I have also seen it working from my dev environment and i would intermittently get the above response from the service. I have moved over to using live data (still from my machine). There is no reason for the imports to fail as they all contain a last name.

I have scoured the internet for any relevant information and have come up blank.

I am using a post request in the following way...

byte[] bytes = Encoding.ASCII.GetBytes(requestParameters); WebRequest request = HttpWebRequest.Create(url) as WebRequest; request.ContentLength = bytes.Length; request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; using (var swRequest = request.GetRequestStream()) { swRequest.Write(bytes, 0, bytes.Length); } 

The request URL (minus the domain) looks like this: /webservice.php?operation=create

The requestParameters variable looks like this (anonymised the data where there was data):

operation=create&sessionName=660f54e47e39358ce&element={"leadsource":"blaah","cf_757":"blaah","salutationtype":"0.","firstname":"blaah","lastname":"blaah","email":"blaah","phone":"blaah","description":"blaah","cf_833":"blaah","emailoptout":"1","cf_761":"1","cf_759":"1","cf_763":"1","assigned_user_id":"19x5"}&elementType=Leads 

in the response i get back i receive the error below for nearly every record.

MANDATORY_FIELDS_MISSING: lastname does not have a value.

Last name and assigned user are the only mandatory values needed and the assigned user is the id returned from the login.

Is anybody able to provide some help on this? i have spent hours on it with no success.

2
  • Possibly a problem with encoding or escaping. 1) You are using ASCII encoding. If your names contain any non-ASCII characters they will be replaced with ?. Try encoding with unicode instead. 2) Then pass the string through HttpUtility.UrlEncode. Commented Feb 18, 2015 at 15:27
  • You should use a web debugging proxy tool like Telerik Fiddler or the Live HTTP Headers firefox browser plugin to view the headers being sent. Compare the headers that are sent when you use your HttpWebRequest code versus what the headers look like when you do the process manually in a browser and try to match the headers as best as possible in your code. I would recommend to omit the Accept-Encoding header though unless you are downloading a file as this will cause issues in your code. Commented Feb 18, 2015 at 18:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.