Post

4 followers Follow
0
Avatar

REST changeState Task - unable to set to '"On Hold"

G'day

I am putting a utility together to take a Work Breakdown Structure template in Excel and create the Tasks in Clarizen directly from the Sheet. I have the REST API working, but want to tweak it so that they can update the tasks.

Problem: using the changeState call I can make a task state = "Draft", "Active",... but cannot set it to "On Hold"

making a POST to https://api.clarizen.com/v2.0/services/data/changeState

Payload is: {"ids":["/Task/oim41b575uunk0rk9ghtbed94650"], "state":"On Hold"}

{"errorCode":"Internal","message":"An internal error has occurred, the error was logged and will be examined.","referenceId":"3JaMw06LqkFyntcmZqHR5"}

Have tried many variations on upper and lower cases.

And Note the same call works for 'Active' or 'Draft' State

Pete

Peter O'Halloran Answered

Official comment

Avatar

Hi Peter,

Please use value "OnHold".

 

I hope this helps,

Elad

Elad Franklin
Comment actions Permalink

Please sign in to leave a comment.

7 comments

0
Avatar

Hi there.

what is wrong with my syntax? '{"Ids":["\Project\TESTJ006"]},{"state":"Active"}'

Thank you.

Julzbergholdt 0 votes
Comment actions Permalink
0
Avatar

Hi, 

I assume this is for /V2.0/services/data/changeState 

If so, I think the syntax should be:

{
"ids": [
 "\Project\TESTJ006"
],
"state": "Active"
}

I hope this helps.

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar
Thank you Roland for responding.  I made the changes but it still did not work.
I verified the ServerLocation 'https://api2.clarizen.com/v2.0/services'
I verified the mycontenttxt as '{"ids": ["\Project\TESTJ006"],"state": "Active"}' before it's written to myContent.
And, I verified this project exists with state: Draft
local procedure ChangeState(CLID: text; NewState: Text)
  begin
      if NewState = '' then
          exit;
      mycontenttxt := '{"ids": ["' + CLID + '"],"state": "' + NewState + '"}';
      myContent.WriteFrom(myContentTxt);
      if myHttpClient.Post(ServerLocation + '/data/changeState', myContenttxt, myResponse) then begin
          if not myResponse.IsSuccessStatusCode then
              Error('Response says this was not successful %1 %2', myResponse.HttpStatusCode(),
                      myResponse.ReasonPhrase());
      end ELSE
          Error('My post did not work.');
  end;
Julzbergholdt 0 votes
Comment actions Permalink
0
Avatar

actually... my code below had said myContext and NOT myContexttxt... i thought i'd give that a try too. but that won't work because of type mismatch

 

Julzbergholdt 0 votes
Comment actions Permalink
0
Avatar

Hi, which language are you using? I've just tested this in Postman and it worked fine: https://www.screencast.com/t/7HMiPA7Q

I think the problem is in your code. In JS, this would be the correct code I think: 

var data = JSON.stringify({
 "ids": [
   "/Project/33d8mj56td3uj2j4bfzmex3z1548"
 ],
 "state": "Draft"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
 if(this.readyState === 4) {
   console.log(this.responseText);
 }
});
xhr.open("POST", "https://api.clarizen.com/V2.0/services/data/changeState");
xhr.setRequestHeader("Authorization", "Session xxx");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);

Best regards,

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Thank you Roland.  I'm using AL which is the language used for Microsoft Dynamics Business Central.

I got my code to work!! Finally!  I needed to clear MyContent and then switch the \ to / on my project id.

Julzbergholdt 0 votes
Comment actions Permalink