title: Google Vision - OCR - Request must specify image and features
body: <p>I am trying to Implement Google Vision OCR Request. Here is My Code,</p>
  
  <pre><code> func performImageRecognition(image: UIImage){
  
      //1. Convert Image into base64 encoding
      let imageData: Data = UIImageJPEGRepresentation(image, 1.0)!
      let encodedString: String = imageData.base64EncodedString()
  
      //2. Request Body for Vision OCR
      let postBody: [String: Any] = getPOSTBody(base64: encodedString)
  
      //3. API Call
      AppDelegate.makeRequest(url: Request.url, requestBody: postBody, completionHandler: {
          data, response, error in
          print(error!)
  
          do{
              let dictionary = try JSONSerialization.jsonObject(with: data!, options: [])
              print(dictionary)
              self.activityindicator.stopAnimating()
          }catch{
              print("Error Parsing Data: \(error)" )
          }
  
      })
  
  }
  
  /*
   * Request Body
   */
  func getPOSTBody(base64: String) -&gt; [String: Any]{
  
      let json: [String: Any] = [
          "requests": [["image": ["content": base64]],
                       ["features": [["type": "TEXT_DETECTION"]]]
                      ]
      ]
  
      return json
  }
  </code></pre>
  
  <p>Request Handler</p>
  
  <pre><code>class func makeRequest(url: URL, requestBody: [String: Any],completionHandler: @escaping (Data?, Int?, String?) -&gt; Void){
  
      var requestData: Data!
      var urlRequest = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60)
  
      // 1. Serialize the request body to Data
      do{
          requestData = try JSONSerialization.data(withJSONObject: requestBody, options: [])
      }catch{
          print("ERROR:: Generating data from JSON Body : \(error) ")
      }
  
      // 2. Setting up the required Header Fields
      urlRequest.httpBody = requestData
      urlRequest.addValue("\(requestData.count)", forHTTPHeaderField: "Content-Length")
      urlRequest.addValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")
      urlRequest.httpMethod = "POST"
  
      // 3. Creating the Session
      let session = URLSession(configuration: .default)
      let dataTask: URLSessionDataTask = session.dataTask(with: urlRequest, completionHandler: {
          data, response, error in
  
          if (error != nil){
              print("Error is: \(error?.localizedDescription ?? "None")")
              return
          }
  
          let resp = response as? HTTPURLResponse
  
          DispatchQueue.main.async {
              completionHandler(data, resp?.statusCode ?? 0, error?.localizedDescription ?? "None")
          }
  
      })
  
      dataTask.resume()
  }
  </code></pre>
  
  <p>Problem is getting "Bad Request, 400 Status, Request must specify image and features.". </p>
  
  <p>I've Checked the Request body for <code>isValidJSONObject</code>, getting true. API is working fine on Postman.
  Please let me know if i am missing something, Any Help will be appreciated.</p>
  
  <p>Thank You</p>