The Community is now in read-only mode to prepare for the launch of the new Flexera Community. During this time, you will be unable to register, log in, or access customer resources. Click here for more information.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CLOUD WorkFlow - Debuging/Throubleshooting

williamtaka
By
Level 4

hi,

i need to create a http post request with content type "application/x-www-form-urlencoded",

I have created a request, but it's not working:

###############################################################################
# Cloud Workflow
###############################################################################

define ibm_add_tags($data,$tags_to_add, $$rs_optima_host, $api_key) return $all_response do
$$debug=true
$all_response=[]
$tags_obj={}

$response = http_request(
verb: "post",
host: "iam.cloud.ibm.com",
href: "/identity/token",
https: true,
headers:{
"Host": "iam.cloud.ibm.com",
"Content-Type": "application/x-www-form-urlencoded"
},
body: join(["grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey&apikey=", $api_key])

)

$all_response << $response

end

I use the same request in Datasource definition and works well:

###############################################################################
# Datasources
###############################################################################

datasource "ds_ibm_auth" do
request do
host "iam.cloud.ibm.com"
verb "POST"
path "/identity/token"
header "Host", "iam.cloud.ibm.com"
header "Content-Type", "application/x-www-form-urlencoded"
body join(["grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey&apikey=", $param_api_key])
end
result do
encoding "json"
collect jmes_path(response,"[@]") do
field "access_token", jmes_path(col_item,"access_token")
end
end
end

 

Any idea how to do this request?

How can i debug my code in cloud workflow? How can I log the response for throubleshooting?

 

(3) Replies

JohnSorensenDK
By Moderator Moderator
Moderator

@williamtaka 

In the code provided you seem to be missing the access token in the CWF workflow (field "access_token", jmes_path(col_item,"access_token")) or did you do this deliberately to avoid exposing it here?

Thanks,

Hi John,

The "access token" is a token to access my account.

I did this deliberately to avoid exposing it here

The "http request" above is correct, it works, but sometimes I get errors and I can't debug what's going on

 

 

Please refer to How to get logs from cloud workflow 

Thanks,