Error when trying to create/update a custom form

341 Views Asked by At

I've been assigned to work on a project that uses the AtTask API to create an issue and accompanying custom form from a web application I've built for our intranet. I've been using this post, ATTask API - Updating Custom Field with API and C Sharp, as my main starting reference for accomplishing my task.

Like that post, I'm also getting (500) Internal Server Error, though the error I receive the URL is inserted directly into the browser is {"error":{"class":"com.attask.util.json.JSONException","message":"org.codehaus.jackson.JsonParseException: Unexpected character ('S' (code 83)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: java.io.StringReader@45c828e1; line: 1, column: 6]"}}.

My URL looks like this:

https://myCo.attasksandbox.com/attask/api/v3.0/optask?method=put&projectID=myID&name=API%20SandBox%20Issue&updates={DE:Service%20Affected:Electronic%20Communications,DE:Technical%20Details:I%20dunno,DE:How%20will%20this%20change%20be%20communicated?:It%20wont}&username=myUserName&password=myPassword

I have noticed that one difference between the post I reference above and my URL is that the other post's URL is looking for a categoryID. Is that necessary for working with Custom Forms? If so, where do I find that ID? (I did a search query on an issue that had custom form of the kind I'm trying to generate, but no categoryID was returned).

By the way, my search query looks like this:

Console.WriteLine("**Searching for Change Management Issues");
        JToken cmIssues = client.Search(ObjCode.ISSUE, new
        {
            projectID=cmProjID,
            name="SandBox Issue",
            name_Mod="contains",
            fields="parameterValues"
        });
        foreach (JToken issue in cmIssues["data"].Children())
        {
            Console.WriteLine(issue["name"]);
            Console.WriteLine(issue["categoryID"]);
            Console.WriteLine(issue);
        }

I've used both ISSUE & OPTASK ObjCode types, with no luck on the categoryID.

2

There are 2 best solutions below

0
On BEST ANSWER

After finally being able to come back to this project, I found that my problems lay with my unfamiliarity with JSON calls. For this particular issue, (after the I fixed the spelling of password), I was receiving my error because I had surrounded neither the custom form object I was sending nor the related value in quotation marks.

Basically, my problem was that I was doing this:

DE:The Object:The Value

when I should have been doing this:

"DE:The Object":"The Value"
1
On

Try removing the sessionID. At the end you are using your username & password, you do not need both. Make sure you spell password correctly. In your example you spelled it wrong.

If that does not work. Make sure all the spaces are replaced with %20 by UrlEncode it before you send the call.