You need to sign in to do that
Don't have an account?

Basic HTTP Authentication for REST service
Hi,
I have exposed a custom REST service through Apex code. I have given the following curl command to get the data from the API and it works fine if passed the session id in the header.
curl https://na30.salesforce.com/services/apexrest/testservice -H 'Authorization: Bearer 00D36000000wE02!ARAAQNag09f5_h7z8_ArS_JFo6f1o9Ag4C7y201UJDlyP66MSE1YrL7brsqS5CmCOO5' -H 'X-PrettyPrint:1'
But when I tried to use the Basic HTTP authentication it gives me below error. I have encoded the username and the password with base64
curl https://na30.salesforce.com/services/apexrest/testservice -H 'Authorization: Basic <username:password>'
[ { "message" : "Session expired or invalid", "errorCode" : "INVALID_SESSION_ID" }]
What I'm doing wrong here. Do I need to make any change in the back end code as well?
I have exposed a custom REST service through Apex code. I have given the following curl command to get the data from the API and it works fine if passed the session id in the header.
curl https://na30.salesforce.com/services/apexrest/testservice -H 'Authorization: Bearer 00D36000000wE02!ARAAQNag09f5_h7z8_ArS_JFo6f1o9Ag4C7y201UJDlyP66MSE1YrL7brsqS5CmCOO5' -H 'X-PrettyPrint:1'
But when I tried to use the Basic HTTP authentication it gives me below error. I have encoded the username and the password with base64
curl https://na30.salesforce.com/services/apexrest/testservice -H 'Authorization: Basic <username:password>'
[ { "message" : "Session expired or invalid", "errorCode" : "INVALID_SESSION_ID" }]
What I'm doing wrong here. Do I need to make any change in the back end code as well?
This is one example that work fine
So the client will be passing : Authorization: Basic <username:password>
Username:Password is encoded in Base64. Normally its working for other rest service. Not sure why its not working in Salesforce.