Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

merrickdrfc

macrumors 6502
Original poster
Jan 8, 2011
474
133
Doncaster / Berlin
I am a little bit stuck on how to fill in the below form using ASIFormDataRequest in the iOS SDK.

An example of the code in the ASP form is below:

Code:
<form name="shipment_form" method="POST" action="shipment.asp" onSubmit="return form_check();">
              <input type="hidden" name="action" value="send_enquiry">
                <table width="312"  border="0" cellpadding="0" cellspacing="4" id="Form table">
                  <tr align="left" valign="middle"> 
                    <td colspan="2"><span class="intro-highlight-text">CONTACT 
                      DETAILS </span></td>
                  </tr>
                  <tr align="left" valign="middle"> 
                    <td width="106">Company</td>
                    <td width="232"> <input name="company" type="text" class="textfield-height" id="Company" size="20" maxlength="50"> 
                    </td>
                  </tr>
                  <tr align="left" valign="top"> 
                    <td width="106">Company Address</td>
                    <td width="232"> <input name="address1" type="text" class="textfield-height" id="Address1" size="20" maxlength="80"> 
                      <input name="address2" type="text" class="textfield-height" id="Address2" size="20" maxlength="80"> 
                      <input name="address3" type="text" class="textfield-height" id="Address3" size="20" maxlength="80"></td>
                  </tr>

And having looked at the ASIFormDataRequestDocs I have started writing the code:

Code:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setPostValue:[completeData objectAtIndex:0] forKey:@"company"];
[request setDelegate:self];

Can anybody tell me if I'm doing this right? Or how I should go about doing this.

Thanks to all,
 
You're close. I'm not sure if it's the "name" or "id" of a form element that corresponds to the Key for each POST parameter, but it's one of them. Probably "name."

You might want to get a packet sniff of the form being sent from a web browser and your code sending the POST from code.
 
Last edited:
You're close. I'm not sure if it's the "name" or "id" of a form element that corresponds to the Key for each POST parameter, but it's one of them. Probably "name."

You might want to get a packet sniff of the form being sent from a web browser and your code sending the POST from code.

Ok thanks will try using 'name', could you tell me how I could packet sniff a response using my web browser firstly and then the code? I'm new to all this sorry,

Thanks for the help!
 
I still can't get it to work..

This is the URL for the form:

http://www.evolution-timecritical.com/shipment.asp

I am using this code for filling in the table:

Code:
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    [request setRequestMethod:@"POST"];
    
    int totalDataCount = [completeData count];
    
    [request setPostValue:@"send_enquiry" forKey:@"action"];
    
    for (int i = 0; i < totalDataCount; i++) {
        [request setPostValue:[completeData objectAtIndex:i] forKey:[completeKeys objectAtIndex:i]];
    }
    
    [request setPostValue:@"Aircraft Charter" forKey:@"formcontact"];
    
    [request setDelegate:self];
    [request startAsynchronous];


The data is located in an array with an adjacent keys array. I get a response code of 200, but the response string simply contains the code for the html from the original url..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.