Duplicating a project using API

Hi,

I am using API to duplicate a project using python code. Data passed to the API is as below.


data = {"include": [
  "members",
  "notes",
  "task_notes",
  "task_assignee",
  "task_subtasks",
  "task_attachments",
  "task_dependencies",
  "task_followers",
  "task_tags",
  "task_projects"
],
  "name":name,
   "schedule_dates": {
    "due_on": due_on,
    "should_skip_weekends": false,
    "start_on": start_on
},
  "team":team
    }

Below error is displayed.

message

schedule_dates: Value is not an object

Can you please confirm if the above format is correct for setting the values for schedule_dates?

1 Like

Hi @Vinaya_Irodi,

I can see two issues in terms of this portion of the documentation that discusses project duplication and schedule_dates:

task_dates must be included to use this option. Requires either start_on or due_on , but not both.

First, you haven’t included task_dates. Second, you’ve included both start_on and due_on which isn’t allowed.

Try correcting those two things and see if that helps.

Updated the code as below. Still facing the same issue.

data = {“include”: [
“members”,
“notes”,
“task_notes”,
“task_assignee”,
“task_subtasks”,
“task_attachments”,
“task_dates”,
“task_dependencies”,
“task_followers”,
“task_tags”,
“task_projects”
],
“name”:name,
“schedule_dates”: {
“due_on”: due_on,
“should_skip_weekends”: false
},
“team”:team
}

1 Like

Hmm. I’ve never used the schedule_dates feature of that API endpoint so I’m afraid I can’t be of any help from personal experience.

@Ross_Grambo any ideas here?

Hey @Vinaya_Irodi,

I tried postman with the below data and it works as expected.

{"data": {
	"include": [
	"members",
	"notes",
	"task_notes",
	"task_assignee",
	"task_subtasks",
	"task_attachments",
	"task_dates",
	"task_dependencies",
	"task_followers",
	"task_tags",
	"task_projects"
	],
	"name": "Example",
	"schedule_dates": {
		"due_on": "2019-05-21",
		"should_skip_weekends": false
	},
	"team": "1234567890"
	}
} 

So I tried python2.7 and python3 with:

job = client.projects.duplicate_project("1234567890", {
        "include": [
            "members",
            "notes",
            "task_notes",
            "task_assignee",
            "task_subtasks",
            "task_attachments",
            "task_dates",
            "task_dependencies",
            "task_followers",
            "task_tags",
            "task_projects"
        ],
        "name": "Example",
        "schedule_dates": {
            "due_on": "2019-05-21",
            "should_skip_weekends": False
        },
        "team": "1234567890"
    }
)

And both of those worked as expected. You should confirm that your variables are turning into strings appropriately.

Hope this helps,
Ross

1 Like

Hi Ross,

Variables are turning into correct string values. I see the issue exists only for the data that is inside the paranthesis { }.

“schedule_dates”: {
“due_on”: “2019-05-21”,
“should_skip_weekends”: False
}

If I remove schedule_dates parameter then the project gets created. I am using ZAP application and using python code inside ZAP.

@Vinaya_Irodi,

Is ZAP short for Zapier? If so, you’ll need to reach out to them to debug this, as it’s not an issue in our code.

Yes, Ross. It is Zapier.

I have already logged a ticket with Zapier and they had asked for log from POSTMAN for successful call.

I’d recommend using the body I gave earlier ^ and doing the postman call so you can share the logs with them. You’ll be hitting the https://app.asana.com/api/1.0/projects/{project_gid}/duplicate endpoint, and you’ll need to set an Authorization header to “Bearer {your_PAT}”.

Yes, Ross. I have already shared the POSTMAN log with them.

1 Like