Web Service SaaS connecor Customizer `

We have application where Update user use case involves performing an update operation on a user object, which first requires obtaining a lock-id.

To obtain this lock-id, we need to send a GetUser request with the request header “lock” = true. The service then returns the lock-id in the response header of this call.

In most scenarios where the lock-id is part of the JSON response body, a simple two-step process would work. However, since the lock-id is only provided in the response header, the implementation is more complex.

Our intended operation sequence is:

1. Lock the user object prior to performing the update.

2. Send a GetUser call with request header “lock” = true.

3. Retrieve the lock-id from the response header.

4. Parse the lock-id from the response header.

5. Execute the PUT update operation, including the parsed lock-id in the request header.

Could you please advise on how to achieve this using the Web Service SaaS connector customizer?

Hey MC,

You can retrieve the authentication token from the response header via an “after operation” rule.

Inside the after operation rule:
restClient.getReponseHeaders()

Here’s a link to a thread on the developer forum with the same use case: Retrieve Custom authentication token from response header

Hi Dalton,

we can do this via VA based connector but I am looking to achieve this for Web Service SaaS connector where no such concept of before or after connector rule but there is customizer

so can we parse lock-id from response header in Web Service SaaS connector?

Thank you,

HI MC, You can write Webservices before operation rule to initiate the request and capture the lock id and also initiate the 2nd request once you have the lock id.

Example on how to get the response header:

Header headers = response.getAllHeaders(); 	
for (Header header : headers) { 		
System.out.println("Key : " + header.getName()  		      + " ,Value : " + header.getValue()); 	}  	//get header by ‘key’ 	
String server = response.getFirstHeader(“Server”).getValue();
}