API create_task is giving an error, here is my code & hash. l'd love a sample

I have gone through all types of documentation and videos in an attempt to find a sample JSON to successfully post to the API.  I have attempted to "create_contact" and "create_task_category" through the API and have been successful in them both, but what I really need is to "create_task".  I am using Ruby and here is both hashes I haved attempted to send and the code I am using.

Insightly2.api_key = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

new_task = {
"TITLE"=>"Test",
"PUBLICLY_VISIBLE"=>true,
"COMPLETED"=>false
}

task_test = {
"TITLE": "Title2",
"PUBLICLY_VISIBLE": true,
"COMPLETED": false
}

 

begin

    Insightly2.client.create_task(task: another_test)

rescue Insightly2::Errors::ClientError => e
   

    puts "Insightly create_task failed: #{e}"

end

 

user@ubuntu:~/Documents/insightly-api$ ruby insightly_api.rb
I, [2017-09-28T10:48:40.462740 #8441] INFO -- : INSIGHTLY starting [post] request to [Tasks] with payload: {:TITLE=>"Title2", :PUBLICLY_VISIBLE=>true, :COMPLETED=>false}
Insightly contact create failed: Insightly2::Errors::ClientError

 At first, I read that RESPONSIBLE_USER and OWNER fields were required, but then I read and found that they weren't.  If someone could tell me what is wrong in my fields, I would greatly appreciate it.  Or give me some sample data in JSON format that will successfully post a new task, or just tell me what I am doing wrong, I would greatly appreciate it.  Thanks alot.

0

Comments

1 comment
  • Hi Michael,

    It looks like you already had this answered in your ticket, but for others coming to this at a later date I've posted the reply below:

    "For OWNER_USER_ID, you can just put 0. The POST call will override whatever you put with the User ID of the API Key making the call anyway. If you want to make someone else the owner, you'd have to do a PUT call to update the task with a different Owner User Id. In that case, I'd recommend doing a GET on Users to get their User Id. You can store these User Ids locally if you'd like so that you don't always have to make a query since these should never change.

    In the case of RESPONSIBLE_USER_ID, you can send that as null or just leave it out. I was able to do a POST without one using PostMan on v2.2."

    0
    Comment actions Permalink

Please sign in to leave a comment.