Naming Form-Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mandanarchi
    New Member
    • Sep 2008
    • 90

    Naming Form-Data

    When sending form-data via post, the code to name it (I believe) is <form name="somename" >.

    If I interpret that correctly, that is the name of the full packet of data contained within the form tags.

    I need to send multipart/form-data via POST; and I need the name to be xmlmsg.
    The problem is, I'm using VBA (from access 2003).

    I can do the whole POST thing fine, but setting the request headers is proving troublesome.

    I've tried posting in the access/vba forums but I haven't had any responses in over a week, so I guess either no one knows; or I worded it very badly.

    I've tried all the below. (One at a time, obviously). Could someone possibly tell me where I've gone wrong here?

    Code:
    SetRequestHeader="Content-Disposition", "form-data: name=""xmlmsg""" 
    SetRequestHeader="Content-Disposition", "name=""xmlmsg""" 
    SetRequestHeader="Content-Disposition", "name='xmlmsg'" 
    SetRequestHeader="Content-Disposition", "name=xmlmsg" 
    SetRequestHeader="ContentDisposition", "name=""xmlmsg""" 
    SetRequestHeader="name", "xmlmsg"
    I've searched through google and the above is the results of my unsuccessful searches.

    I apologise if my posting here annoys someone, (wrong board or whatever), but I'm having no luck anywhere else and I figured someone who knows html might know how to set headers in VBA.

    Thanks
    Mandi
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    See if this link helps.

    Comment

    • mandanarchi
      New Member
      • Sep 2008
      • 90

      #3
      Originally posted by acoder
      See if this link helps.

      Unfortunately not I'm afraid :(

      I emailed the people who sent me the spec for this, and they didn't even have the decency to look at my name. The response was similar to "He should use the example we sent."

      1, how many blokes do you know called Mandi?
      2, I've already told them, twice, that I use VBA and haven't got any way to change that at the moment. Their examples are php and .NET. GAH!

      Thanks anyway.
      Mandi

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Show the PHP example. Maybe it could be converted. Any reason why you must use VBA?

        Comment

        • mandanarchi
          New Member
          • Sep 2008
          • 90

          #5
          I have nowhere to host PHP reliably at the moment; and I don't have the software to use the .NET example they gave me. All I can reliably use is VBA.

          Here's the php they gave me; copied straight from their documentation but with the website removed for privacy etc.

          Code:
          <?php
          $td_sku="1088963";
          //Following the XML data
          $xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r
          <OnlineCheck>\r
          <Header>\r
          <BuyerAccountId>------</BuyerAccountId>\r
          <AuthCode>---------</AuthCode>\r
          <Type>Full</Type>\r
          </Header>\r
          <Item line=\"1\">\r
          <ManufacturerItemIdentifier/>\r
          <ResellerItemIdentifier/>\r
          <DistributorItemIdentifier>$td_sku</DistributorItemIdentifier>\r
          <Quantity>1</Quantity>\r
          </Item>\r
          </OnlineCheck>";
          $fp = fsockopen("somewebsite.com", 8080, $errno, $errstr, 15);
          //Generate the postdata on a valid way, $out4 needs to be calculated, so will be later.
          $out1 = "POST /Onlchk HTTP/1.0\r
          ";
          $out2 = "Content-Type: multipart/form-data; boundary=---------------------------2\r
          ";
          $out3 = "Host: somewebsite.com:8080\r
          ";
          $out5 = "Connection: close\r
          \r
          ";
          $out6 = "-----------------------------2\r
          ";
          $out7 = "Content-Disposition: form-data; name=\"onlinecheck\"\r
          \r
          ";
          $out8 = "\r
          -----------------------------2--";
          //Calculation of the Content-Length:
          $tlen=strlen($out6)+strlen($out7)+strlen($xmldata)+strlen($out8);
          $out4 = "Content-Length: $tlen\r
          ";
          //Generate full output
          $out = $out1.$out2.$out3.$out4.$out5.$out6.$out7.$xmldata.$out8;
          fwrite($fp, $out);
          $retval = "";
          while(!feof($fp)){$retval = "$retval".fgets($fp,128);}
          fclose($fp);
          list($headers,$body) = explode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",$retval);
          $doc = new DOMDocument();
          $doc ->LoadXML($body);
          $item_ids = $doc->getElementsByTagname( "OnlineCheck" );
          foreach( $item_ids as $item )
          {
          $error_s = $item->getElementsByTagName( "Errorstatus" ); $tderror = $error_s->item(0)->nodeValue;
          $stock_s = $item->getElementsByTagName( "AvailabilityTotal" ); $tdstock = $stock_s->item(0)->nodeValue;
          // Reformatting the price to ISO compatible format
          $price_s = $item->getElementsByTagName( "UnitPriceAmount" ); $tdprice = str_replace('.','',$price_s->item(0)->nodeValue);
          $tdprice=str_replace(',','.',$tdprice);
          }
          //Rest of handling off the data under here
          ?>

          Comment

          Working...