Creating a new program in marketo

Anonymous
Not applicable

Creating a new program in marketo

Hi,

I am trying to create a new program in marketo using api calls.I am using the following post call according to documentation.

Function-Post

https://068-qnu-696.mktorest.com/rest/asset/v1/programs.json

Headers-

Authorization- Bearer "accesstoken"

Content-type-application/x-www-form-urlencoded

Body-name=new hello&folder={"id":14,"type":"Folder"}&description=Sample API Program&type=Default&channel=Email Blast&costs=[{"startDate":"2015-01-01","cost":2000}]

name=new hello&folder={"id":14,"type":"Folder"}&description=Sample API Program&type=Default&channel=Email Blast&costs=[{"startDate":"2015-01-01","cost":2000}]

But i am getting the following response-

{

  "requestId": "c980#15a4b368a9c",

  "success": false,

  "errors": [

    {

      "code": "709",

      "message": "Invalid folder type for program"

    }

  ]

}

Can someone help fix this issue?

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a new program in marketo

You can't create a program in the default Emails folder. This is true in the UI as well, obviously.

Anonymous
Not applicable

Re: Creating a new program in marketo

Can you please share what exactly should I change in my call so that i will be able to create a program?

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a new program in marketo

Can you please share what exactly should I change in my call so that i will be able to create a program?

Choose an extant folder in Marketing Activities. No idea why you'd try to target Design Studio, as this doesn't work in the UI.

Also, when you actually POST form-urlencoded data, there should be no literal spaces (they are encoded to "+") and no literal JSON delimiters, either. Looks you're not actually posting in this format, if that's the literal payload you've pasted above. Make sure you're using a real HTTP library... don't do this by hand.

Anonymous
Not applicable

Re: Creating a new program in marketo

Hi,

The call I am using is referenced from the marketo developer documentation. I am new to this field and so am not clear on which folder to use.If you can share a working payload for creating a program it will be really helpful.Thanks in advance.

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a new program in marketo

The call I am using is referenced from the marketo developer documentation.

The developer docs don't reference Folder ID 14 as far as I know.  Where do you see that ID?

I am new to this field and so am not clear on which folder to use.If you can share a working payload for creating a program it will be really helpful.

You do have a working payload... if you use a valid folder ID. But someone else can't tell you what a valid folder ID is in your instance. That's instance-specific info and you either need to use the API or the UI to identify a valid parent folder.

Honestly, if you're totally new to the field of HTTP APIs there's going to be a lot to learn. For example, you have to understand how to properly form-urlencode a payload. This method to call to do this will be different depending on the language and/or framework you're using. In plain PHP, it's urlencode(). That's just one of tons of methods.

Anonymous
Not applicable

Re: Creating a new program in marketo

Hey,

i am able to create programs now.Thanks for the help.

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating a new program in marketo

OK. Note one full, correctly encoded payload looks like this:

name=Hello+New+Program&folder=%7B%22id%22%3A1525%2C%22type%22%3A%22Folder%22%7D&description=Sample+API-Created+Program&type=Default&channel=Email+Blast

If your payload doesn't look like this, you'll eventually have problems. Marketo mixes outer form-urlencoding with inner JSON encoding. While the endpoint is somewhat forgiving, some data will be incorrectly decoded unless correctly encoded all the way through.