0

I have rest controller with GET, DELETE and POST. GET and DELETE work ok.

@RestResource(urlMapping='/test123')
global class TestRest {

    @HttpGet
    global static String getOperation(){
        return 'ok get';
    }

    @HttpDelete
    global static String deleteOperation(){
        return 'ok delete';
    }

    @HttpPost
    global static String postOperation() {
        return 'ok post';
    }
}

The problem is that when I send POST( using Postman ) to this endpoint I receive response for GET. This code works ok in another org. So, is there any setting, configuration, etc. that I should change?

  • can you copy and paste your request as curl? It's hard to answer without your request body – kurunve Dec 7 '17 at 12:55
  • With token of test user(but there is no diffreance when I use administrator's token): curl -v -XPOST -H 'Authorization: Bearer 00D0O000000sgma!AQ0AQOu0xzsKA3oqaQpftaNkl5guLGauSv.kIfcQMN.utvRAK6l0Yr3Pl73Jsbt7pP4pgyvms79S563xHnO.KdUlI6WDNN0E' -H "Content-type: application/json" 'donkeymoney-dev-ed.lightning.force.com/services/apexrest/…' – sawim Dec 7 '17 at 13:00
  • Idk, it works fine when I do post -- curl -H 'Authorization: Bearer 00D0O000000sgma!AQ0AQOu0xzsKA3oqaQpftaNkl5guLGauSv.kIfcQMN.utvRAK6l0Yr3Pl73Jsbt7pP4pgyvms79S563xHnO.KdUlI6WDNN0E' -H "Content-type: application/json" 'na11.salesforce.com/services/apexrest/test123' -v -XPOST -H "Content-length:0" Probably, there is some issue with postman or so – kurunve Dec 7 '17 at 13:09
  • I've made request with curl and I got good response. After that I repeated request with Postman and surprisingly got a proper answer. To sum up, after 2 days debuging I've done nothing and it finally works. Thank you for your help – sawim Dec 7 '17 at 13:21
  • Please, change your password to the org ASAP -- cause with that token everyone in the world can access your org and break things there :) – kurunve Dec 7 '17 at 13:33
0

Ok, accidentally I found this "bug". POST https://donkeymoney-dev-ed.lightning.force.com/services/apexrest/test123 returns GET, but POST https://donkeymoney-dev-ed.my.salesforce.com/services/apexrest/test123 is OK :) If you find similar bug in your own orgs I will report it to Salesforce

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.