How to get sequence numbers for a campaign using v1 API

I am trying to figure out how to get sequence IDs for a specific campaign, using the v1 API. I have the campaign ID. As best I can tell, I need to use the “restfulRequest()” function call in the Infusionsoft library I’m using along with the ‘optional_properties=sequences’ parameter in order to get sequence numbers. This gives me a call that looks like this:

    $urlToCall = 'https://api.infusionsoft.com/crm/rest/v1/campaigns/{campaignId}?optional_properties=sequences';
    $campaignInfo = $infusionsoft->restfulRequest('get',$urlToCall,[$campaignNumber]);

But when I try to execute this, I get an ‘invalid token’ error. I then tried adding the auth token as a second GET parameter:

    $urlToCall = 'https://api.infusionsoft.com/crm/rest/v1/campaigns/{campaignId}?accessToken=' . $accessToken . '&optional_properties=sequences';

and I get the same thing.

If I completely remove the attempt to get optional properties:

$urlToCall = ‘https://api.infusionsoft.com/crm/rest/v1/campaigns/{campaignId}’;
$campaignInfo = $infusionsoft->restfulRequest(‘get’,$urlToCall,[$campaignNumber]);

then I get a “General server error”.

What am I doing wrong?

Before making a request to the REST API, you have to using the OAuth2 or API Key Authentication.

If this is for a single client, the API Key authentication will work.

If you’re developing an application to work with Keap accounts to offer in the marketplace, then you’ll need to work with OAuth.

Hi Marion. Thanks for replying.

I do have a valid authentication token, and it should be incorporated into the $infusionsoft variable referred to in my code. I know it’s valid because I can do other function calls with it, including getting a list of campaigns with this call:

    $urlToCall = 'https://api.infusionsoft.com/crm/rest/v1/campaigns';
    $campaignInfo = $infusionsoft->restfulRequest('get',$urlToCall);

This works, but trying to do anything with a specific campaign fails. What am I missing?

I just tried it using Postman, and I was able to get back a valid response.

If you’re using a PAT… does that user account have permission to Campaigns?

Re: “does that user account have permission to Campaigns?”

I don’t know. How do I find out?

Log in to Keap, Under the Admin Menu click Users. Clickthe Edit Permissions link next to the user who created the PAT.

Once you’re in the users permissions, click on the Marketing tab, and scroll down to the Automation section and check the permissions there.

Hello Marion,

I was busy with other issues for a while, but now I’ve come back to this and I still can’t get it to work. I am using the admin login for the account, so permissions are not a problem. I’ve used your screenshot to rewrite the url exactly. I still can’t get a valid response - over and over, it tells me “Error: Bad request. Your client has issued a malformed or illegal request.” No details on what’s wrong.

How am I supposed to be providing the token in the Postman request? Your screenshot doesn’t show, and that’s the only other thing I can think of that I might be doing wrong.

Click on the Authorization tab.

Authorization → Auth Type → Bearer Token, and enter the SAK in the Token field.

Hi Marion,

Ahh, now I see what I had wrong. I still couldn’t get it to work, so I rechecked everything and finally realized I had a blank parameter checked in the Body tab. No wonder it wasn’t working. Remove that, and now it works.

Thanks for your help!