VMware Cloud Community
jbo1982
Contributor
Contributor
Jump to solution

[VRO][vCloud 9.5][Branding] request to change logo

Hello VMware Communities,

i am working on a company who would like to create a workflow in VRO in order to change the logo of the vCloud Directory portal.

The vCloud swagger API is giving me this request to execute ::

PUT /branding/logo

Sets the system level logo

I cannot manage to fill correctly the input needed :

pastedImage_1.png

I am using in parallel the postman application and i can manage to change the log easily.

So my question is :

How to do the same process as Postman but within VRO action ?

Thanks in advance for any of you who has a reply for this.

Best regards

Joel B.

1 Solution

Accepted Solutions
jbo1982
Contributor
Contributor
Jump to solution

hello i finally found the solution to be able to update logo on vcd portal using resthost and vcd branding rest api.

As the content of a resourceElement is converted to String, the conversion to binary data is complex. In order to upload a new logo, i have to choose SVG format for my logo. This format is an XML format (therefore a text format).

input of action is :

- vcdRestHost ( restHost type)

- content (String type) (it is XML string representation of the SVG image.

    var httpMethod = "PUT";

    var queryString = "/cloudapi/branding/logo";

    var contentApi = content;

    var tokenContent = System.getModule("com.sfr.library.vcloud.api.branding.operations").getVCDTokenForBranding(vcdRestHost);

    tokenType = "Bearer";

    var authorization = tokenType + " " + tokenContent;

    System.debug("### Done ###");

    request = vcdRestHost.createRequest(httpMethod, queryString, contentApi);

    request.setHeader("Content-Type", "image/svg+xml");

    request.setHeader("Authorization", authorization);

    var response = request.execute();

View solution in original post

Reply
0 Kudos
4 Replies
Raducanu
Enthusiast
Enthusiast
Jump to solution

You should become familiar with the ReST Plugin of vCO.

For me it take some time to understand how ReST in vRO works.

Easiest way is to create a ReST Host and add a new ReST Operation for updating.

Or you start directly with Scripted Tasks and something like this

var url = "RESTHost.url" + "/branding/logo"

var body = "YOURBODY"

var request = RESTHost.createRequest("PUT",url,body);

request.setHeader("Content-type", "*/*");

request.setHeader("x-vcloud-authorization", token);

var response = request.execute(); 

RESTHost is an input Parameter filled with your ReST Host. And don't forget to receive the x Cloud Auth Token first and provide them...

jbo1982
Contributor
Contributor
Jump to solution

Hello

thanks for the reply. I am using VRO for 2 years now and i am familar with rest api usage (restHost/restOperation/...).

The token is retrieved and correct. The restHost is operational.

    var method= "PUT";

    var query= "/cloudapi/branding/logo";

    var content = <what to put here>;

        request = vCDRestHost.createRequest(method, query, content);

        request.setHeader("Accept", "application/json; version=31.0");

        request.setHeader("Authorization", token);

        request.setHeader("Content-Type", "image/png");

        var response = request.execute();

The response is alway OK (HTTP statusCode value equal to 204) but when i check the web portal presentation, the LOGO part is not displaying image correctly.

pastedImage_2.png

in my different tries i have coded 2 solutions but none of them are working.

//    var contentApi = "base64,"+Base64.encode(logo.getContentAsMimeAttachment().content);

//    var contentApi = logo.getContentAsMimeAttachment().content;

Reply
0 Kudos
jbo1982
Contributor
Contributor
Jump to solution

This topic on the communities helps me a lot to understand for css transfer part on the customization process of the branding

HTTP-REST plugin - how to PUT binary content?

This official URL from VMWare is given the same example :

https://www.eehelp.com/question/http-rest-plugin-how-to-put-binary-content/

But I still have issue for picture (image/png).

Reply
0 Kudos
jbo1982
Contributor
Contributor
Jump to solution

hello i finally found the solution to be able to update logo on vcd portal using resthost and vcd branding rest api.

As the content of a resourceElement is converted to String, the conversion to binary data is complex. In order to upload a new logo, i have to choose SVG format for my logo. This format is an XML format (therefore a text format).

input of action is :

- vcdRestHost ( restHost type)

- content (String type) (it is XML string representation of the SVG image.

    var httpMethod = "PUT";

    var queryString = "/cloudapi/branding/logo";

    var contentApi = content;

    var tokenContent = System.getModule("com.sfr.library.vcloud.api.branding.operations").getVCDTokenForBranding(vcdRestHost);

    tokenType = "Bearer";

    var authorization = tokenType + " " + tokenContent;

    System.debug("### Done ###");

    request = vcdRestHost.createRequest(httpMethod, queryString, contentApi);

    request.setHeader("Content-Type", "image/svg+xml");

    request.setHeader("Authorization", authorization);

    var response = request.execute();

Reply
0 Kudos