Error When Refreshing Access Token Using Power Automate

SOLVED
Go to solution
MarcusC952
Rookie
0 Votes

We leverage Microsoft Power Automate for calling the CC API for various tasks without issues (e.g. get contacts, delete contacts, etc.). These have been manual, one-off runs of these processes using an access token generated through Postman.

 

We want to automate these processes to run daily, which requires refreshing the access token with the process. However, making the POST to obtain a new access token fails each time with the following error.

 

{
"errorCode": "E0000021",
"errorSummary": "Bad request. Accept and/or Content-Type headers likely do not match supported values.",
"errorLink": "E0000021",
"errorId": "oaerLte4bS6QKqfxodU6E_--w",
"errorCauses": []
}

 

The call is using the same parameters and headers as the call in Postman, so I'm not sure what the problem is. Obviously it is something specific with Power Automate and how it makes the POST call.

 

URI: https://authz.constantcontact.com/oauth2/default/v1/token?refresh_token=[Refresh Token]&grant_type=refresh_token

Headers: {
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded"
}

 

I'm wondering if anyone else in the community has encountered this and if you were able to work around this. Without being able to automate this step, we're stuck with a manual process.

1 ACCEPTED SOLUTION
MarcusC952
Rookie
0 Votes

Thank you for the resource links! One of the resources referenced another article that ended up having the solution.

 

For anyone else wanting to accomplish the same thing... When using the Power Automate HTTP action, you need to include the request parameters in the body instead of the URI like you would in Postman.

 

You don't need to do this for GET requests for some reason, but POST requests appear to require it this way.

 

MarcusC952_0-1685723424154.png

 

View solution in original post

2 REPLIES 2
Courtney_E
Employee
0 Votes

Hello MarcusC952,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

As Power Automate / Microsoft Flow is a 3rd party product and not built or supported by Constant Contact, we are limited in the support we can provide, but will try to answer any questions to the best of our ability as they pertain to Constant Contact’s API endpoints and functionality.

 

From what we understand, the issue that many users run into regarding using Power Automate  with Constant Contact's V3 API is how to refresh the token set (access token and refresh token), as our access tokens only have a lifespan of 24 hrs.

 

I was able to find some related 3rd party resources below that may offer some additional insight on possible resolutions if needed, but if you need further assistance with setting up an Oauth2 authentication within Power Automate / Microsoft Flow, you’d want to reach out to Microsoft's support team directly for assistance: 

 

[3rd party link] https://powerusers.microsoft.com/t5/Building-Flows/OAuth-2-how-to-re-authenticate-refresh-an-expired...

 

[3rd party link] 

https://stackoverflow.com/questions/67811804/capturing-user-authentication-and-refresh-tokens-power-...

 

As far as setting up a daily sync, the V3 OAuth2 Authorization Code Flow will likely be the best option:

 

V3 API - OAuth2 Authorization Code Flow

https://v3.developer.constantcontact.com/api_guide/server_flow.html

 

While our expertise is with our API itself as opposed to its implementation within any particular programming language and Constant Contact doesn’t offer any services as far as assisting with building custom integrations, we are happy to answer any questions pertaining to Constant Contact’s API endpoints, functionality, and documentation.

 

If you'd like, we're happy to provide more detailed steps regarding the authorization process, endpoint calls, and call schemas, to request this, please feel free to email our team directly at webservices@constantcontact.com and reference case # 31210141.

 

Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
MarcusC952
Rookie
0 Votes

Thank you for the resource links! One of the resources referenced another article that ended up having the solution.

 

For anyone else wanting to accomplish the same thing... When using the Power Automate HTTP action, you need to include the request parameters in the body instead of the URI like you would in Postman.

 

You don't need to do this for GET requests for some reason, but POST requests appear to require it this way.

 

MarcusC952_0-1685723424154.png

 

Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up