title: Intercept Request and add Parameters in WKWebView
body: <p>I tried to intercept a request and add request parameters based on the following code  </p>
  
  <pre><code>- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
  NSURL * actionURL = navigationAction.request.URL;
  if ([actionURL.host isEqualToString:kMyHost]) {
      NSString * headerField = @"Authorization";
      NSString * headerValue = [NSString stringWithFormat:@"Bearer %@", accessToken];
      if ([[navigationAction.request valueForHTTPHeaderField:headerField] isEqualToString:headerValue]) {
          decisionHandler(WKNavigationActionPolicyAllow);
      } else {
          NSMutableURLRequest * newRequest = [navigationAction.request mutableCopy];
          [newRequest setValue:headerValue forHTTPHeaderField:headerField];
          NSMutableString *params = [[NSMutableString alloc] initWithData:[newRequest HTTPBody] encoding:NSUTF8StringEncoding];
          [params appendFormat:@"is_app_web_view=1&amp;utm_source=ios"];
          [newRequest setHTTPBody:[[self encodeToPercentEscapeString:params] dataUsingEncoding:NSUTF8StringEncoding]];
          decisionHandler(WKNavigationActionPolicyCancel);
          [webView loadRequest:newRequest];
      }
  } else {
      decisionHandler(WKNavigationActionPolicyAllow);
  }
  }  
  </code></pre>
  
  <p>I found that setting only http header works but once i add following lines of code, the request is not sent:</p>
  
  <pre><code>        NSMutableString *params = [[NSMutableString alloc] initWithData:[newRequest HTTPBody] encoding:NSUTF8StringEncoding];
          [params appendFormat:@"is_app_web_view=1&amp;utm_source=ios"];
          [newRequest setHTTPBody:[[self encodeToPercentEscapeString:params] dataUsingEncoding:NSUTF8StringEncoding]];    
  </code></pre>
  
  <p>Is this the proper way of adding the parameters? Can someone point me to the right direction regarding this?</p>