0

I am trying to access Attachment info using /services/data/v56.0/sobjects/Attachment/\<attachment-id\> which works fine from workbench.

It also works fine from Anonymous window using URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v56.0/sobjects/Attachment/\<attachment-id\>.

However, when I am trying to run it from Apex class (called from Partner Portal LWC component), it always return Status=Not Found, StatusCode=404 in the response.

This is how I am setting the request.

req.setMethod('GET');
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v56.0/sobjects/Attachment/\<attachment-id\>');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());

Is there anything which I am doing in incorrect manner?

2
  • The session you establish via LWC doesn't have enough privileges to see the attachment or the attachment ID you're providing doesn't exist in this org. (Workbench could be connected to a different org)
    – identigral
    Dec 8, 2022 at 17:17
  • @identigral - Workbench is connected to same org. We don't have multiple orgs. if it is issue with session privileges', how can I check that and fix it?
    – farooq.ind
    Dec 9, 2022 at 19:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy