Issue With Patching Source Connector Attributes Using Java

Hi,

I am trying to add connector attributes to an existing source using the update-source | SailPoint Developer Community api in Java. I managed to get this right in postman but the same request returns Response{protocol=h2, code=400, message=, url=https://<TENANT>.api.identitynow.com/v3/sources/<sourceId>} in my code. According to the documentation, this error is returned if the request body is invalid.

Below is a sample of my code, please assist.

Map<String, Object> thisMap = new HashMap<>();
thisMap.put("op", "add");
thisMap.put("path", "/connectorAttributes/supportUnstructuredData");
thisMap.put("value", true);

listAttributes.add(thisMap);

Gson gson = new GsonBuilder().setPrettyPrinting().create();
String attributesAsString = gson.toJson(listAttributes);

I then pass the attributesAsString to a function that executes the below

@PATCH("v3/sources/{sourceId}")
@Headers("Content-Type: application/json-patch+json")
Call<Source> patchConnectorAttributes(
      @Path("sourceId") String sourceId,
      @Body String connectorAttributes
    );

I intercepted the request to print out the request body it displays : Request Body: "[\n {\n \"op\": \"add\",\n \"path\": \"/connectorAttributes/supportUnstructuredData\",\n \"value\": true\n }\n]" which I thought would work, but alas.

I would appreciate any assistance regarding the issue, thank you in advance.

Hi @Bhekamandla ,

Is the API method used as PATCH in the code ? update-source API with this body format needs a PATCH.

Also, can you add a header for “Accept” : “application/json”

Thanks,
Shailee

Hi @shaileeM,

Yes, the method is used as a patch. I added the header as per suggestion but issue persists.

Thanks

Hi,

I managed to resolve the issue by changing the Body input of patchConnectorAttributes from a String to a RequestBody. I created the RequestBody from the Json String attributesAsString.

:smiley: :smiley:

1 Like

Glad to hear that! Thank you for sharing