ATTask API-使用API​​和C Sharp更新自定义字段 [英] ATTask API - Updating Custom Field with API and C Sharp

查看:83
本文介绍了ATTask API-使用API​​和C Sharp更新自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中对非自定义字段的API运转良好,但是该文档似乎与解释使用c Sharp更新自定义字段的实际放置请求格式实际上并没有什么作用.

I have the API functioning fine within my project for non custom fields, but the documentation doesn't really seem to work in relation to explaining what the actual put request format should be for updating a custom field using c sharp.

我有以下内容:

PROJECT类型的自定义字段,称为"TestNumber".

Custom Field of type PROJECT called "TestNumber".

我可以轻松地通过网络请求进行搜索:

I can easily search it with the web request:

/attask/api/proj/search?sessionID=XXXXXXX&ID=XXXXX&fields=DE:TestNumber

所以我知道该特定自定义字段的语法是正确的.

so I know that the syntax for that specific custom field is right.

我还可以对非自定义字段进行基本更新:

I can also do a basic update on non custom fields:

/attask/api/proj?method=put&sessionID=XXXXX&id=XXXXX&name=TEST RESOURCES` 

它会正确更新.

但是无论做什么,我都无法弄清楚如何将"TestNumber"自定义字段的值更改为使用API​​选择的值.经过一番搜索,我发现我应该使用AtTask的API文档中的"JSON Edits"部分,但是,我似乎找不到正确的语法.

But no matter what I do, I cannot figure out how to change the value of that "TestNumber" custom field, to a value that I choose using the API. After some searching, I found that I should be using the "JSON Edits" portion from the API docs of AtTask, however, I can't seem to figure out the proper syntax.

尝试之前,我的完整网址是:

My fullurl prior to the attempt is:

/attask/api/proj?method=put&sessionID=XXXXX&id=XXXXXX&updates={DE:TestNumber:1234}

(这似乎与API DOCS息息相关,请参见 http://developers.attask .com/api-docs/#JSONEdits ),但每次都会出现 500内部服务器错误.

(which seems to jive with the API DOCS rec here http://developers.attask.com/api-docs/#JSONEdits) but I get a 500 Internal Server error every time.

我已确认我已正确登录.

I have verified that I am being properly logged in.

任何建议都将不胜感激.

Any suggestions or advice would be greatly appreciated.

更新: 我仍然无法使它正常工作.我发现了另一篇文章(搜索在自定义复选框字段中更新AtTask API的多个值"),该人在自定义复选框表单中提到了此问题:

UPDATE: I still cannot get this to work. I found another post (search for "AtTask API Updating Multiple Values in Custom Checkbox Field") where the person mentioned this for a custom checkbox form:

PUT /attask/api/v3.0/task/xxxxxxxxxxxxxxxxxx?updates={DE:Labels=["a","b","c"]}

但是我不确定如何使用C Sharp直接传递此类数据,因为它不允许双引号,并且当我添加转义字符时,仍然会出现 500内部服务器错误 .我可以通过使用%22代替引号来使用发布"方法,但是无论我在看跌期权中做什么,它都行不通.

but I am not sure how to even pass that sort of data directly using C Sharp because it does not allow double quotes and when I add an escape character, I still get the 500 internal server error. I got the "Post" method to go by using %22 in the place of the quotes, but no matter what I do on the put, it does not work.

我们的AtTask顾问提到我可能需要在自定义表单中包括我的categoryId,因此我也将其添加到了查询字符串中,但无济于事.

Our AtTask consultant mentioned that I might need to include my categoryId for the custom form, so I also added that to my querystring, but to no avail.

我已经下载了C Sharp(位于developers.attask.com上)的"AtTask示例",并尝试使用他们通过以下示例作为示例的Update方法:

I have downloaded the "AtTask Example" for C Sharp (which is located on the developers.attask.com)and am trying to use the Update method that they use as the example passing the following:

JToken project = client.Update(ObjCode.PROJECT, new { 
    ID = projectId, categoryID = "XXXXXXXXXXXXXXXX", 
    updates = "{DE:Total Feet of Line:1234}" });

正如我之前提到的,搜索"工作正常,并且返回的正是我期望的值:

As I mentioned before, the Search works fine and returns exactly what I expect:

JToken projects = client.Search(ObjCode.PROJECT, new { 
    ID = projectId, 
    fields = "DE:Total Feet of Line" });

这将生成以下网址:

/attask/api/proj/search?sessionID=XXXX&ID=XXXX&categoryID=XXXXX&fields=DE:Total Feet of Line

我终于尝试使用带有非自定义字段的"Json Edits"进行更新,并且它与put方法一起使用,因此我在这些字段上的语法一定有问题,但是我确定应该是DE:FIELDNAME:"VALUE" .我在这里错了吗?

I finally tried updating using "Json Edits" with non custom fields, and it works with the put method so I MUST have something wrong with my syntax on those fields, but I was CERTAIN that it is supposed to be DE:FIELDNAME:"VALUE". Am I wrong here?

在解决这个问题上,我感觉自己处在正确的轨道上,但是我很难相信没有人支持或这样做.似乎能够从API更新自定义字段是基本需要...

I feel like I am on the correct track in terms of trying to solve this, but am finding it hard to believe that there is no support or other people who have done this. It seems like it is a basic need to be able to update a custom field from the API...

我也尝试完全按照其他示例使用自定义复选框,即使搜索"按预期返回json,更新"也会失败.

I also tried exactly following the other individuals example with a custom checkbox, and even though the "Search" returns the json as expected, the "Update" fails.

推荐答案

您对"DE:FIELDNAME":"VALUE"的看法是正确的.

You are right about "DE:FIELDNAME":"VALUE".

尝试使用以下URL更新自定义字段:确保更改MYCOMPANY,YOUR_ID,YOUR_CAT_ID,YOUR_FIELD,YOUR_VALUE,YOUR_LOGIN_USERNAME,YOUR_LOGIN_PASSWARD.

Try the following url to update the custom field: Make sure you change MYCOMPANY, YOUR_ID, YOUR_CAT_ID, YOUR_FIELD, YOUR_VALUE, YOUR_LOGIN_USERNAME, YOUR_LOGIN_PASSWARD.

MYCOMPANY.attasksandbox.com/attask/api/proj?updates = {"ID":"YOUR_ID","categoryID":"YOUR_CAT_ID","DE:YOUR_FIELD":"YOUR_VALUE"}& method = put&用户名= YOUR_LOGIN_USERNAME&密码= YOUR_LOGIN_PASSWARD

MYCOMPANY.attasksandbox.com/attask/api/proj?updates={"ID":"YOUR_ID","categoryID":"YOUR_CAT_ID","DE:YOUR_FIELD":"YOUR_VALUE"}&method=put&username=YOUR_LOGIN_USERNAME&password=YOUR_LOGIN_PASSWARD

对我有用.让我知道这是否适合您

That works for me. Let me know if that works for you

这篇关于ATTask API-使用API​​和C Sharp更新自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆