1

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.

  • 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 May 27 at 16:12
  • Hi @RedDevil I just edited it. – Salvation May 27 at 16:23
  • That's really strange....Can you post the debug log? Also what API version is this class? – PartOfTheOhana May 27 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 May 28 at 7:52
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.

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

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.