Error on PresenceApi#patchUserIdPresencesSourceId

I am trying to change the presence for a user but keep getting Status 405. (See below)

When I try to change the presence from Postman it seems to work fine.

Do you know what could be wrong?

09:24:00,153 ERROR [stderr] (MSC service thread 1-5) SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
09:26:10,127 ERROR [stderr] (GT-X UniversalController_qdof2tjw0G4Buh6lXegS6Rdc.localhost-ekp_1) Exception when calling PresenceApi#patchUserIdPresencesSourceId
09:26:11,465 ERROR [stderr] (GT-X UniversalController_qdof2tjw0G4Buh6lXegS6Rdc.localhost-ekp_1) com.mypurecloud.sdk.ApiException: {"status":405,"code":"method not allowed","message":"HTTP 405 Method Not Allowed","contextId":"557438bc-782d-4f6c-8c6d-cc66462895c5","details":[],"errors":[]}
09:26:11,469 ERROR [stderr] (GT-X UniversalController_qdof2tjw0G4Buh6lXegS6Rdc.localhost-ekp_1)        at com.mypurecloud.sdk.ApiClient.invokeAPI(ApiClient.java:627)
09:26:11,471 ERROR [stderr] (GT-X UniversalController_qdof2tjw0G4Buh6lXegS6Rdc.localhost-ekp_1)        at com.mypurecloud.sdk.api.PresenceApi.patchUserIdPresencesSourceId(PresenceApi.java:305)

Can you show me a code snip of your code where you're doing this?

Sure. I have tried various combinations- including sample code @ https://developer.mypurecloud.com/api/rest/client-libraries/java/latest/PresenceApi.html#patchUserIdPresencesSourceId but keep getting the same error.

Current code:

	PresenceApi apiInstance = new PresenceApi();
	UserPresence body = new UserPresence();		
	body.setPrimary(true);
	body.setMessage("a message about my presence");						
	body.setPresenceDefinition(getPresenceDefinitionFromName(state));		
	System.out.println(MODULE_NAME + "Body: "+body.toString());
	
	try {	
		UserPresence result = apiInstance.patchUserIdPresencesSourceId(uniqueUserId, PureCloudChannelProviderConstants.PRESENCE_SOURCEID, body);		
		System.out.println(MODULE_NAME + result);		
	
	} catch (ApiException e) {
		System.err.println("Exception when calling PresenceApi#patchUserIdPresencesSourceId");
		e.printStackTrace();
	}

Ugh. The short answer is that the Jersey HTTP client doesn't support the PATCH method and they are refusing to fix it. Working on figuring out a workaround for the SDK.

Should be fixed with this: https://developer.mypurecloud.com/forum/t/sdk-update-down-with-jersey-all-hail-apache/187/1

1 Like