1, the normal delete simply add the following sentence code:
[Request setrequestmethod:@ "DELETE"];
2, with the case of the Parameter form (one delete request):
Asiformdatarequest *request; Nsurl *baseurl = [Nsurl urlwithstring:@ "http://www.baidu.com/xx/"]; request = [Asiformdatarequest requestwithurl:baseurl]; Header [Request addrequestheader:@ "Authorization" value:headerforauthen]; Form [Request Setpostvalue:username forkey:@ "Userpair_name"]; Call this before setting request method [Request Buildpostbody]; Construction request [request setrequestmethod:@ "DELETE"]; Set Agent [request setdelegate:self]; Set timeout [request settimeoutseconds:10]; URL request failed handling [request Setdidfailselector: @selector (Urlrequestfailed_deleteuserpair:)]; URL request successfully processed [request Setdidfinishselector: @selector (Urlrequestsuccessed_deleteuserpair:)]; Asynchronous transmission [Request startasynchronous]; return YES;
Description
Existing data to be submitted:
[Request Setpostvalue:username forkey:@ "Userpair_name"];
Add only
[Request setrequestmethod:@ "DELETE"];
This line of code does not implement the delete correctly,
Need to add
[Request Buildpostbody];
Also note that the setrequestmethod:@ "DELETE" line is after buildpostbody.
Reference: Stackoverflow:http://stackoverflow.com/questions/15518394/asiformdatarequest-with-setpostvalue-and-method-delete