0

Right now we are developing a service for mobile to obtain the labels that are stored in tridion (mobile publication) in a Core component that it's attached to the Publish settings page.

First I tried to obtain the information using the Model service, but because the page template it’s a JSON template the pagemodel service fails so I tried to do it in another manner and I can find this information by obtaining the Binaries using the content.svc service like in the call below

Call 1 http://domain:8183/client/v2/content.svc/BinaryContents(BinaryId=147,PublicationId=5,VariantId='cmVzb3VyY2Vz')/$value

the variantId I have found it by calling this endpoint

Call2 http://domain:8181/client/v2/content.svc/Binaries(BinaryId=147,PublicationId=5)/BinaryVariants

but publicationId 5 it’s a desktop language, but in the response I can see all the binaries of the component 147 in all languages except for the mobile publication that its 78, so I tried to call this service with publication id 78 but in the response is the same, so I tried to call the service with publication 78 and the same variantID and it works

Call 3 http://domain:8183/client/v2/content.svc/BinaryContents(BinaryId=147,PublicationId=78,VariantId='cmVzb3VyY2Vz')/$value

So one of the questions that I want to ask is

• Why Call 1 returns all the binaries for all the publications and why publications of mobile are not shown? (Something to take into account is that our mobile applications don’t have a web app application, our app gets content information from our spring boot application via restful calls, and we use CIL lib and Model service to communicate with tridion)

• Where does the VarientID come from?

• Is VarientID the same for all instances of the binary in all publications?

2 Answers 2

1

To clarify to understand you correctly.

I would say you won't worry about the VariantID anymore, you stick to use CIL API to get the images by Id or URL, In case if you looking to get the specific binary with specific VariantId then there is a CIL API function to get the metadata of the binary by URL with publication Id it will return the information of VariantID and BinaryId informations, then you can use that information to get the value of the Binary, In the backend CIL API converted to RestAPI to get the content from broker DB, that's the Rest URLs you have referenced in your question.

Refer to this question answer for Java CIL example How to get the binary file from Broker DB using CIL?

Refer to SDL Documentation for Adding raw binaries to a Web page

If you look at your Call 1 URL VariantId= cmVzb3VyY2Vz (base64 decode value resources), It means in your case it's looking for resources json file.

AFAIK - Most of the cases OOTB Binaries used on the components get published VariantID default is [#def#] (base64 encode value WyNkZWYjXQ==), same for all the binaries, unless if you do any customization in the TBBs to publish the binary with custom VariantId in your template code.

Note:

In DXA Framework TBBs - for publish-settings page template back-end logic it's customized and used different VariantId's for system assets, config, mappings, and resources JSON's binaries (eg all.json or core.json)

I hope it helps.

1

Maybe it helps to have a look at how DXA uses the CIL API to retrieve Binaries?

https://github.com/sdl/dxa-web-application-dotnet/blob/release/2.0/Sdl.Web.Tridion/Statics/BinaryFileManager.cs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.