I am making a call to an external link from salesforce. Say the URL for it is xyz.pwc.com/aaaabbbbccccddddrrr. "aaaabbbbccccddddr" is 18 character long and while making the call "aaaabbbbccccddddrrr" is getting trimmed to 15 characters and call is failing
Id someId = '001J000001eun1Q';
Which will automatically convert it for you:
system.debug(someId); // 001J000001eun1QIAQ
Then you can simply call the getSObjectType() method on the Id variable which will return the object name:
Schema.SObjectType objectType = someId.getSObjectType();
system.debug(objectType); // Account
https://salesforce.stackexchange.com/questions/94080/how-to-get-an-18-digit-id-from-15-digit-id-using-soql