• Ryan Raymundo 1
  • NEWBIE
  • 10 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
Hello everyone, Just wanted to ask why my SOQL query is not working inside @RestResource?
 
List<Account> recordToUpdate = [Select id from Account where id = '001Dn00000PideYIAR' LIMIT 1];
System.debug(!recordToUpdate.isEmpty());

This code inside @RestResource returns false, which means that it can't get any record. 
But if I run the same code inside the Developer Console it returns true. Why is that?User-added image 
Also using Query Editor shows a record
User-added image

Any help would be appreciated. Thanks in advance!

Regards,
Ryan

 

Hello everyone,
I have created an endpoint (@RestResource), made it public, and able to accept calls which works. Now I wanted to just add some simple authentication. Since the call is from another system webhook I dont have any control, I can only check the basic auth value and compare it before I process the JSON body. 

My issue is I cant get the basic authorization using this code: 
RestRequest req = RestContext.request;
        if (req.headers.get('Authorization') == null)
        {
            // always goes here
            authorizationHeaderValue = 'Null';
        }

Any ideas? Thanks in advance!
Hello everyone,
I'm relatively new to Salesforce development, but I've started creating a Lightning Web Component (LWC) designed to send SMS messages to contacts using their mobile numbers. Up to this point, I've successfully created a simple page and integrated it into the Contacts page, allowing me to use an API to send SMS messages.

However, I have a new question: How can I place this LWC not on a page but have it displayed as an icon in the bottom left corner? When clicked, it should expand or pop up. Can anyone point me in the right direction? Any links or blogs that will be able to help me accomplish this? Thanks in advance. Please see the image below
User-added image
I have created an apex class @RestResource and with @HttpPost, now how can it handle webhook w/o authentication?
Hi Everyone,

I have created an endpoint that handles POST requests. It works well if I'm using a bearer token. but since the design is to handle webhooks, I can only supply basic Auth. How can I accomplish this? I have tried this but I'm getting 
[
    {
        "message": "INVALID_HEADER_TYPE",
        "errorCode": "INVALID_AUTH_HEADER"
    }
]

Thanks in advance,
Ry
Hello everyone,

I would like to ask how to handle this payload going to SF.

{
  "WebhookId": "1152",
  "MessageId": "79bfa6ba-b350-415f-ae29-8b98bc534b98",
  "To": "+11111111111",
  "From": "+12222222222",
  "Body": "Test Message",
  "Attachments": [],
  "MessageEventType": 1,
  "MessageStatus": 2,
  "Time": "2023-09-01T17:08:43.3133"
}

Since this is a webhook I do not have control over the fields. Now I'm getting errors for "From" and "Time" fields because it's reserved.

This does not work as well because of how the payload is structured

@HttpPost
    global static String doPost( String requestBodyJson ) {
Map<String, Object> requestBodyMap = (Map<String, Object>)JSON.deserializeUntyped(requestBodyJson);
....

Anyone who has an idea would be greatly appreciated.

Thanks in advance,
Ry
 
Hello everyone,
I have created an endpoint (@RestResource), made it public, and able to accept calls which works. Now I wanted to just add some simple authentication. Since the call is from another system webhook I dont have any control, I can only check the basic auth value and compare it before I process the JSON body. 

My issue is I cant get the basic authorization using this code: 
RestRequest req = RestContext.request;
        if (req.headers.get('Authorization') == null)
        {
            // always goes here
            authorizationHeaderValue = 'Null';
        }

Any ideas? Thanks in advance!
Hello everyone,
I'm relatively new to Salesforce development, but I've started creating a Lightning Web Component (LWC) designed to send SMS messages to contacts using their mobile numbers. Up to this point, I've successfully created a simple page and integrated it into the Contacts page, allowing me to use an API to send SMS messages.

However, I have a new question: How can I place this LWC not on a page but have it displayed as an icon in the bottom left corner? When clicked, it should expand or pop up. Can anyone point me in the right direction? Any links or blogs that will be able to help me accomplish this? Thanks in advance. Please see the image below
User-added image
I have created an apex class @RestResource and with @HttpPost, now how can it handle webhook w/o authentication?
Hi Everyone,

I have created an endpoint that handles POST requests. It works well if I'm using a bearer token. but since the design is to handle webhooks, I can only supply basic Auth. How can I accomplish this? I have tried this but I'm getting 
[
    {
        "message": "INVALID_HEADER_TYPE",
        "errorCode": "INVALID_AUTH_HEADER"
    }
]

Thanks in advance,
Ry
Hello everyone,

I would like to ask how to handle this payload going to SF.

{
  "WebhookId": "1152",
  "MessageId": "79bfa6ba-b350-415f-ae29-8b98bc534b98",
  "To": "+11111111111",
  "From": "+12222222222",
  "Body": "Test Message",
  "Attachments": [],
  "MessageEventType": 1,
  "MessageStatus": 2,
  "Time": "2023-09-01T17:08:43.3133"
}

Since this is a webhook I do not have control over the fields. Now I'm getting errors for "From" and "Time" fields because it's reserved.

This does not work as well because of how the payload is structured

@HttpPost
    global static String doPost( String requestBodyJson ) {
Map<String, Object> requestBodyMap = (Map<String, Object>)JSON.deserializeUntyped(requestBodyJson);
....

Anyone who has an idea would be greatly appreciated.

Thanks in advance,
Ry