fhanimkhudri Valued Contributor.
Valued Contributor.
700 views

Getting Unauthorized error "Failed to create session. You must provide a valid Authorization header"

Jump to solution

Hi,

I'm trying to create an OO content pack which used HTTP Client Multipart Post to call Mulesoft CloudHub API to do automatic deployment.

The request header consist of the following (+ access_token from previous step)

 X-ANYPNT-ENV-ID string

The ID of your current environment

 

The request body consist of the following:

appInfoJsonrequired, string

application attributes in json format

autoStartboolean

boolean flag to autostart the application after it is deployed

filerequired, file

Contents of a Mule application file

 

I have created a simple flow to get the access_token and pass it to the HTTP Client Multipart POST to run the API call but keep getting this error:

 

{returnResult={"error":"Unauthorized","message":"Failed to create session. You must provide a valid Authorization header"};Result={"error":"Unauthorized","message":"Failed to create session. You must provide a valid Authorization header"};}

redeploy_flow.PNGheader.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

error.PNG

  

The step was successfully tested using Postman app.

Any advice on how to resolve this error? Thanks in advance for any feedback.

 

Reference:

1. CloudHub API Reference

2. Using CloudHub API

0 Likes
1 Solution

Accepted Solutions
fhanimkhudri Valued Contributor.
Valued Contributor.

Re: Getting Unauthorized error "Failed to create session. You must provide a valid Authorizatio

Jump to solution

The Unauthorized error resolved by adding 

authorization:Bearer ${access_token}

in the header input which was not required when tested in Postman app.

2 Replies
fhanimkhudri Valued Contributor.
Valued Contributor.

Re: Getting Unauthorized error "Failed to create session. You must provide a valid Authorizatio

Jump to solution

The Unauthorized error resolved by adding 

authorization:Bearer ${access_token}

in the header input which was not required when tested in Postman app.

AndreiTruta Outstanding Contributor.
Outstanding Contributor.

Re: Getting Unauthorized error "Failed to create session. You must provide a valid Authorizatio

Jump to solution

It is the good approach. Great you fixed it.

Some similar samples here.

Andrei Vasile Truta
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.