function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dejan CvetkoskiDejan Cvetkoski 

rest

Anyone help me. I send json object with webhook to  /services/apexrest/myService/test, but i can't reseve them, my class is 
@RestResource(urlMapping='/myService/test/*')
global class myWeb {
	 @HttpGet
    global static void sayHello() {
        RestRequest request = RestContext.request; 
        RestResponse response = RestContext.response;
        String accountId = request.requestURI.substring(request.requestURI.lastIndexOf('/')+1);
        System.debug(accountId);
    }
}

But result after execute is System.NullPointerException: Attempt to de-reference a null object. I need send from woocommerce wordpress plugin with webhooks to salesforce. Anyone help me. Thanks :)
Soumya BeheraSoumya Behera
Hi Dejev,

Hope you have append the account object id in the request URL . 

like /services/apexrest/myService/test/Accountid .


Regards,
Ranjan
Dejan CvetkoskiDejan Cvetkoski
I try send json object from woocommerce on wordpres and when i send response is 
Status: HTTP 401 Unauthorized: [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

But my service works, i chek that on workbandch, i don't know how i can add security token od this. Whatever thanks very much.
Regards,
Dejan
Łukasz BieniawskiŁukasz Bieniawski
Hi Dejan,

You can try to use Post instead of Get method and paste parameters as an attributes, i.e.:
@RestResource(urlMapping='/myService/test/*')
global class myWeb {
	 @HttpPost
    global static void sayHello(String accountId) {
        System.debug(accountId);
    }
}

Hope this helps,
Lukasz