It's not possible to perform a POST request with HTTPBody content in a WKWebView.

Number:rdar://20464240 Date Originated:07-Apr-2015 12:49 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 8.2
Classification:Serious Bug Reproducible:Always
WKWebView will empty the HTTPBody of a POST URLRequest.
Creating a URLRequest with a HTTPBody and using this request to load content in the WKWebView. Will result in the WKWebView emptying the HTTPBody.

Steps to Reproduce:
- Create WKWebView.
- Create a NSMutableURLRequest.
- Set the HTTPMethod of the URLRequest to POST.
- Set some data to the HTTPBody of the URLRequest.
- Make WKWebView perform the URLRequest by `loadRequest:`.
- Track the request that is going out with Charles for instance or use the NSURLProtocol to see the HTTPBody of the request.

Or use this code snippet:

- (void)viewDidLoad
    [super viewDidLoad];
    WKWebView *webView = [WKWebView new];
    webView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:webView];
    NSDictionary *views = @{@"webView": webView};
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[webView]|" options:0 metrics:nil views:views]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[webView]|" options:0 metrics:nil views:views]];
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@""]];
    urlRequest.HTTPMethod = @"POST";
    urlRequest.HTTPBody = [@"test" dataUsingEncoding:NSUTF8StringEncoding];
    [webView loadRequest:urlRequest];

Expected Results:
The request going out to the server will not contain the HTTPBody. This works in UIWebView.

Actual Results:
HTTPBody is nil.

iOS 8.2 (12D508)


iPad air, iPhone 6, iOS simulators


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!