Bynder / bynder-java-sdk

SDK in Java for integration with Bynder
MIT License
4 stars 24 forks source link

Issue modifying an image metadata #102

Closed mkilaru2210 closed 1 year ago

mkilaru2210 commented 1 year ago

Hi Team,

Business Unit is not getting updated in QA Bynder when sending multiple channels in the MediaModifyQuery. But when sending single channel its working fine. PFB the screenshots.

Bynder sdk code we are using for modification: assetService.modifyMedia(mq).blockingSingle();

Can you please check and let me know if I’m doing something wrong or there is code issue in Bynder sdk. Please do let me know if anything else needed.

Screenshot from our code in debug mode where we can see multiple channels are present in MMQ: image

Screenshot of Bynder where we can see none on the channels is updated: image

Screenshot from our code in debug mode where we can see single channel is present in MMQ: image

Screenshot of Bynder where we can see the channel is updated: image

Thanks, Mohan

TimBloembergen commented 1 year ago

Hi @mkilaru2210 I'm not that familiar with JAVA, however from looking at your screenshots it seems you are sending two separate parameters for modifying an existing metaproperty, i.e; metapropertyID = {id} and optionIds = {values}.

To modify a metaproperty (docs) on an asset you need to send the following parameter metaproperty.{metapropertyID} = {string_of_the_optionids}

mkilaru2210 commented 1 year ago

@TimBloembergen -- I have tried sending the business_unit & businessunit values as "NAD,Product_Brands" (String value instead of String array), still I see the same issue. PFB the screenshot.

image
TimBloembergen commented 1 year ago

Hi @mkilaru2210 the parameter only accepts one actual NAME, but you can pass a string of actual optionIds. When you send optionIDs it will accept multiple values. Pending if that metaproperty is configured to accept more than one value (i.e multi-select metaproperties).

But when passing a parameter to modify the value you need to pass this parameter metaproperty.{metapropertyID} = {string_of_the_optionids} and not 2 seperate ones i.e metaproperty="id" and optionids=id.

It's one parameter metaproperty.{metapropertyID} = {string_of_the_optionids}

mkilaru2210 commented 1 year ago

@TimBloembergen -- I tried sending the channels in metaproperty.{metapropertyID} = "NAD,Product_Brands". PFB the screenshot. Still I see same issue. Please let me know if my understanding is wrong. I can setup a call in Zoom if its ok with you so that we can close this ticket. Please share me you emailId and available time so that I can set up a call.

image
TimBloembergen commented 1 year ago

Hi @mkilaru2210 A zoom is unfortunately not possible. But in your latest case, the API does not support sending "NAD,Product_Brands" as the metapropertyIds. See below for a cURL example, hopefully this will clear things up. I'll try to get you a JAVA example.

In my example metaproperty.{metapropertyID} , you need to replace {metapropertyId} with an actual metapropertyId. Then as the payload for that parameter you need to send OptionIds.

curl -X "POST" "https://timbloembergen.getbynder.com/api/v4/media/87F71B9D-78D4-4A2F-B075DED7D36DAB3C/" \ -H 'Authorization: Bearer removed' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "metaproperty.F59C396C-306B-4D1E-BFB973A498A3D48B=F59C396C-306B-4D1E-BFB973A498A3D48B,A4099578-3B5C-47F9-A0678812A5B745E1"

metaproperty.F59C396C-306B-4D1E-BFB973A498A3D48B defines which metaproperty you want to update on an asset. Than as the value for that parameter you send the optionIds you want to set.

MetapropertyIds and OptionIds can be retrieved via https://bynder.docs.apiary.io/#reference/metaproperties/metaproperty-operations/retrieve-metaproperties

mkilaru2210 commented 1 year ago

Thanks for the info @TimBloembergen. When I tried from my postman it throwing 400 error for multiple channels. But when I send single channel its working fine. Can you please check?

curl: curl --location --request POST 'https://staplestest.getbynder.com/api/v4/media/C742FA58-09AC-45D6-80D60BAD5FFB1E5F/' \ --header 'Authorization: Bearer 33d51e26ab087538df7c3820ec9de93547a7b2e26a672ec26de4fc0fa6912d73' \ --header 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --header 'Cookie: DEFAULTLOCALE=en_US' \ --data-raw 'metaproperty.9D20DF31-E80C-4906-9CFBDB88C182A224=Quill,Product_Brands'

Multiple Channels Screenshot:

image

Single Channel Screenshot:

image
thegreatdeku commented 1 year ago

@mkilaru2210

Is the metaproperty field that you are trying to update has the "Multiselect" option selected?

We found that if you don't have the Multiselect option enabled on the metaproperty that you are trying to update, the API will respond with a 400 when trying to update a single-select metaproperty with multiple option IDs. (under "Settings (Gear Icon) -> Taxonomy -> Metaproperties management -> Pencil Icon next to metaproperty) Screen Shot 2023-02-08 at 1 26 24 PM

@ahongbynder and I ran a couple of test cases using the code below (single select, multiselect, text metaproperties). The only case that was giving us a 400 and not updating with multiple option IDs passed in was a "Select" type metaproperty with "Multiselect" unselected.

package org.example;

import com.bynder.sdk.configuration.Configuration;
import com.bynder.sdk.query.MediaModifyQuery;
import com.bynder.sdk.query.MetapropertyAttribute;
import com.bynder.sdk.service.BynderClient;
import com.bynder.sdk.service.asset.AssetService;
import retrofit2.Response;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
public class Main {
    public static void main(String[] args) throws MalformedURLException {
        // Fill in your permanent token here
        String permToken = "*****";

        // Fill in portal URL here
        URL baseUrl = new URL("https://your-portal.bynder.com");
        Configuration sdkConfig = new Configuration.Builder(baseUrl).setPermanentToken(permToken).build();
        BynderClient bynderClient = BynderClient.Builder.create(sdkConfig);

        AssetService assetService = bynderClient.getAssetService();

        // Fill in the target media ID you want to update the metaproperty for
        String mediaId = "***************";

        // Fill in the target metaproperty
        String metapropertyId = "***************";

        // Fill in option IDs here
        String[] optionIds = {"option_id_1", "option_id_2"};

        MediaModifyQuery mq = new MediaModifyQuery(mediaId);
        // metaproperty attribute, metaproperty id and array of string options
        MetapropertyAttribute ma = new MetapropertyAttribute(metapropertyId, optionIds);

        // create list of metaproperty attributes
        List<MetapropertyAttribute> metapropertyAttributes = Arrays.asList(ma);

        // set media modify query with metaproperty attributes
        mq.setMetaproperties(metapropertyAttributes);
        Response<Void> modifyResponse = assetService.modifyMedia(mq).blockingSingle();
        System.out.println(modifyResponse);
    }
}
mkilaru2210 commented 1 year ago

@thegreatdeku / @TimBloembergen / @ahongbynder -- I'm able to see multiple channels when I made the field as MultiSelect in Bynder setting. I will check with my team and let you know if any thing needed.

Appreciate your help !!

image

TimBloembergen commented 1 year ago

Great @mkilaru2210 . I'll consider this resolved. Please let us know if you have any follow up questions.