Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Creating a Proxy Page to POST json

    I have json data that I have to submit to another server. I have been doing all kinds of research and all of the tutorials and guides all seem to say the same thing: I need to have access to the other server to enable somethings on.

    I do not have access to the other server to enable anything.

    I think that this has to be possible to create a proxy to accomplish this but I am unsure of how to start.

    Could any one point me in the right direction?

    Edit#1: I should add that I have created a proxy page to pull information from the external server. I just need to create some thing to push info back to the server.
    Last edited by duyba008; 10-10-2013 at 03:40 PM. Reason: adding more info

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Does that external server allow posting from another domain?

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    use enctype to force the form to submit application/json instead of fromdata or urlescaped...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #4
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    @glenn yes the external server allows for posting from another domain.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    What type of http request (GET or POST) does the external server expect and what are the request parameters and what is the expected output?

  • #6
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That would be a POST. The required paratemeters are is just a string of JSON data. The documentation doesn't tell me what the output will be.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Why not just do a simple form with the action pointing to the external server?

  • #8
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm not sure how to accomplish this with a form. I know about posting via a form but since I'm posting JSON data I'm not sure about how that would take place. I think maybe something like below?

    <form action ='external page' name ='submitForm'>
    <input type = 'text' value = JSON data>
    </form>

    <script>document.forms.["submitForm"].submit</script>

  • #9
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have attempted the above approach and i don't think that it will work as it reidrects to the page.
    <form method="post" action="https://xxxXX@xxxxxx.myshopify.com/admin/1042/fulfillments.json" enctype = "JSON">
    <input type='text' value = '{ "fulfillment":{"tracking_numbers":["919099170050501","919099170050518"]}}'>
    <input type = "submit" value = "POST JSON DATA">
    This approach isn't working as it is attempting to open the external page instead of just POSTing the data to it.

    *I purposely included the xxx's to make sure that the integrity of the external site is maintained
    Last edited by duyba008; 10-29-2013 at 03:03 PM.

  • #10
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    see my post #3. use a hidden iframe with a name attrib, and add that name to the form under a target attrib to prevent re-navigation upon submit.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #11
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    what would I use as the src for the Iframe?

  • #12
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    Quote Originally Posted by duyba008 View Post
    what would I use as the src for the Iframe?
    about:blank or a blank page on your site.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #13
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry but I am confused. (I'm a newb at proxy pages) If I don't put anything in the source for the Iframe, where do I put the address for the external server that I am POSTING to?


    This is what I have so far but it doesn't seem to work
    <iframe src='https://XXXXxXXXXx@XXXX.myshopify.com/admin/#1042/fulfillments.json' name="Submit_JSON">
    </iframe>
    <div id='Content' style="text-align:center; width:650px; border: 1px solid red; border-radius: 15px;">
    <form method="post" action="Submit_JSON" enctype="application/json">
    <input type='text' value = '{ "fulfillment":{"tracking_numbers":["919099170050501","919099170050518"]}}'><br>
    <input type = "submit" value = "POST JSON DATA">
    </form>

  • #14
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    Quote Originally Posted by duyba008 View Post
    Sorry but I am confused. (I'm a newb at proxy pages) If I don't put anything in the source for the Iframe, where do I put the address for the external server that I am POSTING to?
    in the action attrib of the form tag.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #15
    New Coder
    Join Date
    Aug 2013
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well the good news is that I have seemd to make some progress. I'm getting this error though returned when I submit the form:

    A potentially dangerous Request.Path value was detected from the client

    Is that something that I can change on my end.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •