0

I have an irritating problem where I need to pass information and focus from one web application to another, but the source application will only send HTTP POST messages, while the target application will only accept GET messages. I'm not able to modify this part of the applications at all, so I need some scripting in between them.

I would've thought a little script could quite easily run through all the key values pairs and create a GET query that auto submits and redirects, but I'm pretty new to this world, and I'm not having a lot of luck finding information about how I might do this without using PHP, which unfortunately I'm not able to, strictly JS only. Right now I'm so in the dark I'm not even sure how JS would receive the POST values (if it can).

The HTTP POST message contains about 20 kvps, and while I don't need all of them in the GET, I'm hoping to have a loop function that adds them into the GET and which doesn't hard code any of those values in, so it's nice and easy to maintain.

Sorry to be such a dunce, but could one of you smart guys give me some direction?

Sorry if this has been covered anywhere else, I tried searching, honest!

aaeeo
  • 1
  • 1
  • 1
  • Unfortunately, there's no way to look at the POST data, since [it only exists on the server-side](http://stackoverflow.com/questions/1409013/how-to-read-the-post-request-parameters-using-javascript). – Scott Mar 26 '15 at 15:43
  • 1
    Shoot, that's going to be a problem, thanks – aaeeo Mar 26 '15 at 15:45

2 Answers2

0

I'm not able to modify this part of the applications at all, so I need some scripting in between them I'm not even sure how JS would receive the POST values (if it can)

You will have to use server side JS, if you want to use JS.

The below stackoverflow link might help you.

When and how do you use server side JavaScript?

Community
  • 1
  • 1
Albin
  • 371
  • 1
  • 4
  • 18
0

Another way, would be using injected JavaScript, and modifying the local code of your app. (Which can always be modified).

If you use chrome, you can open chrome dev tools (F12), in the sources tab, you can set a XHR breakpoint, where you can stop code when it tries to open a httprequest object. (If you use firefox use ctrl+i to open its console)

You can read the code and try to understand what it does, then you can replace the existing functions with custom ones, changing the web application's behaviour.

The downside of using this method is that you'd take a big investment in trying to understand the webapp code, and sometimes the code is obfuscated making it really hard to do modifications.

This modification is personal which means that no one else but you, (and the people who share your browser session) will be able to use it. Unless you make an userscript and ask people to install it.

You could investigate the variables in the webapp and using the console, make the XMLHttpRequest object yourself, to send the desired data.