简体   繁体   中英

Updating project parameters in AtTask using restsharp put method

I am struggling a little in my project with Attask. My aim is to update the alignmentValues of a project using custom form data.. I have been able to create new alignment values to update but I am unable to execute it using put method... the request I want to execute is

PUT /attask/api/project/4c7...?updates= 
{
    alignmentValues: [ 
        { 
            scoreCardOptionID: "2222...54d0", 
            scoreCardQuestionID : "8897...54d1",... 
        },....
                     ] 
}

my code snippet is

var request = new RestRequest("project/{id}", Method.PUT);
request.AddUrlSegment("id", pid);
request.RequestFormat = DataFormat.Json;
JObject _putData = new JObject();
_putData.Add("alignmentValues",newAnswers);

and for updates object I tried few combinations

request.AddParameter("updates",_putData,ParameterType.RequestBody); //no effect
request.AddBody(new {name = "updates", value = _putData}); //no effect

With this body approach I am even unable to update the name of project. But when I supply the parameters as query string, it successfully updates the name but fails for alignment values as the url becomes too large

var request = new RestRequest("project/{id}?updates=" + _putData , Method.PUT);

Above works if _putData is small...like name = "TEST"..but fails for big json array..

Any suggestions on how to update values using addbody/addobject/addjsonobject/addparameter...because I need to send request in body because of its large size...

Thanks in advance.

Well this is not an answer but I made it to work by fluke.. SO the main problem still remains..I can't use body with PUT request..Even if I use its shows no result..so I had to go with query string only... Now for my problem on big parameters in the query string, I was sending the whole alignmentvalues object where I had to update only two fields within that object. So in a trial and error approach i only passed three fields within the object - answer ID and two fields to be updated...And it reduced the query string size and fortunately for me it worked..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM