简体   繁体   English

使用restsharp put方法更新AtTask中的项目参数

[英]Updating project parameters in AtTask using restsharp put method

I am struggling a little in my project with Attask. 我在与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 我的目的是使用自定义表单数据来更新项目的alignmentValues。.我已经能够创建新的对齐值以进行更新,但是我无法使用put方法来执行它。我要执行的请求是

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 但是当我将参数作为查询字符串提供时,它会成功更新名称,但由于url太大而无法对齐值

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.. 如果_putData很小的话,上面的方法就可以了...就像name =“ TEST” ..但是对于大的json数组失败。

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... 关于如何使用addbody / addobject / addjsonobject / addparameter更新值的任何建议...因为它的大小太大,所以我需要在正文中发送请求...

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. 好吧,这不是一个答案,但我是通过fluke使其工作的。.因此,主要问题仍然存在..我不能将主体与PUT请求一起使用..即使我使用它的显示也没有结果..所以我不得不去仅使用查询字符串...现在,对于我在查询字符串中的大参数问题,我正在发送整个alignmentvalues对象,在该对象中我只需要更新该对象中的两个字段。 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.. 因此,在一种反复试验的方法中,我只在对象中传递了三个字段-答案ID和两个要更新的字段...而且它减小了查询字符串的大小,幸运的是它对我有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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