2

I wrote a web service using @RestResource With both Get and Post methods.

When I try to send a request via workbench - everything works great,

but when I try to send a post request using other tools - like Postman or SoapUI or other online tools -

it always goes to the GET methods even though I picked POST as the method.

BTW - the GET method is working fine.

  @RestResource(urlMapping = '/Tranzilasa/*')
    global class WebServiceaaa {
      @HttpPost
      global static String oppToUpdate() {
        System.debug('POST');
      }

      @HttpGet
      global static String opptoUpdateSync(){
        System.debug('GET');
      }
}

enter image description here

After sending this request I get "GET" in the debug - instead of "POST".

If I using Workbench tool - I get "POST" as is need to be.

4
  • I have used postman before and post works perfectly. I think you may need to add screenshot of what you are doing in postman to provide more clarity
    – RedDevil
    Commented May 27, 2019 at 16:12
  • Hi @RedDevil I just edited it.
    – Salvation
    Commented May 27, 2019 at 16:23
  • That's really strange....Can you post the debug log? Also what API version is this class? Commented May 27, 2019 at 23:02
  • API Version - 42.0 The logs are very long because Its not just the System debug as I posted - It just an example - But the HTTPPOST and HTTPGET is set as I posted and Its not working as expected - except on the WorkBench
    – Salvation
    Commented May 28, 2019 at 7:52

2 Answers 2

1

I got the solution.

Because I'm using Site - I copied the url from there and then I added the suffix :

/services/apexrest/Tranzilasa.

When using POST it MUST be HTTPS and I used HTTP and that why it didn't work correctly.

In the screenshot I attached this part was deleted so you couldn't know it - Sorry about it - I believe you know why I deleted it :)

Thanks anyway for those who tried to help.

0

the postman may retain the get request. Please close all the tabs once and make the request again by selecting POST request on PostMan. If you still you are facing same problem check your url. you may have defined a new rest service somewhere.

1
  • Nop.. not working either. The same URL is used for workbench which there it's working fine. :(
    – Salvation
    Commented May 28, 2019 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .