I have been trying to bulk update data using c# onto workfront,but my code has been returning 400 bad exception. However, when I use the same url on browser it does the update but the code has been returning an exception. Below is my sample code:
string fullUrl = "";
if (!path.StartsWith("/"))
{
path = "/" + path;
}
fullUrl = url + path + ToQueryString(parameters);
if (DebugUrls) Console.WriteLine("Requesting: {0}", fullUrl);
WebRequest request = HttpWebRequest.CreateDefault(new Uri(fullUrl));
Stream responseStream = null;
try
{
//request.Method = "PUT";
//request.ContentType = "application/x-www-form-urlencoded";
WebResponse response = request.GetResponse();
responseStream = response.GetResponseStream();
return ReadResponse(responseStream);
} catch (WebException ex) {
StreamReader sr = new StreamReader(ex.Response.GetResponseStream(), true);
Console.WriteLine(sr.ReadToEnd());
}
return ReadResponse(responseStream);
}
At the end of the code, my full url is like below:
https://osvtrial.attask-ondemand.com/attask/api/v4.0/user?method=post&sessionID=ca748236a1d6455ca96c01aad74b65a6&updates=[{\"name\":\"Marc Johansson\",\"title\":\"Director, Information Technology\",\"emailAddr\":\"[email protected]\",\"username\":\"[email protected]\"}]&username=xxxxxx&password=xxxxx
Could someone help on the above issue, Is the issue with the way the url is being passed as the same url when put on the browser works just fine.
you need to give proper ID of user object which you want to update. Method should be put not post in case of bulk update. Please refer this link. If you are updating single object then you can use try with below api call
to create bulk projects
to update bulk projects