1

I have implemented a code to get a post body data which has been sent through x-www-form-urlencoded header on custom URL. I have used ApexPages.currentPage().getParameters(); but it returns a parameter MAP. So on generating a string of parameter it re-framing a parameter string in alphabetical order. Actually I need a parameters in a same order as it has sent. I also have used URL.getCurrentRequestUrl().getQuery(); but it did not work. Cause the data is getting posted through header. And this function only gets the appended parameters of URL.

I dont have a hold on parameters of post method which I am getting on my custom URL. I am getting these parameters from third party. So i can not include any extra parameters like 'order' or 'serial' in to post data. What i want to do is just to get raw data as it is to post it back to third party for validation. They verifies the string completely.

Is there any method is available to get a raw post data in apex page without changing the order?

2
  • are you using rest api ? – Ratan Paul Dec 31 '15 at 15:08
  • Knowing that the params are not returned in the same order, maybe rethink your code a bit to account for that rather than trying to for it to do something it does not. If you are checking for the existence of params, use loops to check and then see if any were not found. Either way you are going to have to code around it. KeithC provided a good solution. Just depends on the "why" your are doing it – Eric Dec 31 '15 at 18:31
2

If your logic is in a Visualforce page then you can't get the raw post data.

But you can include an "order" parameter that holds the other parameter names in the correct order separated by commas. That can then be used to extract the values in the desired order:

Map<String, String> m = ApexPages.currentPage().getParameters();
String[] orderedNames = new String[] {};
String[] orderedValues = new String[] {};
for (String name : m.get('order').split(',')) {
    orderedNames.add(name);
    orderedValues.add(m.get(name));
}
3
  • Actully, I dont have a hold on post parameters. I am getting these parameters from third party. So i can not include any extra parameters in to post data. What i want to do is just to get raw data as it is to post it back to third party for validation. They verifies the string completely. – Rishi Jan 4 '16 at 7:14
  • @Rishi That is bad news. Suggest you add this point to your question. – Keith C Jan 4 '16 at 8:53
  • Thank you for your reply. I will add this point in my question. Can you get a help for me from salesforce's developer team. – Rishi Jan 5 '16 at 13:29

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.