title: Computer Vision Quickstart not working for Java
body: <p>I am new to computer vision and I am trying to implement the following (<a href="https://github.com/Azure-Samples/cognitive-services-quickstart-code/blob/master/java/ComputerVision/src/main/java/ComputerVisionQuickstart.java" rel="nofollow noreferrer">example</a>), but it always sends me the same error:</p>
  <blockquote>
  <p>Something went wrong: Couldn't extract the operation id from the
  operation location</p>
  </blockquote>
  <pre><code>/**
   * OCR with READ : Performs a Read Operation on a local image
   * @param client instantiated vision client
   * @param localFilePath local file path from which to perform the read operation against
   */
  private static void ReadFromFile(ComputerVisionClient client) {
      System.out.println(&quot;-----------------------------------------------&quot;);
      
      String localFilePath = &quot;C:\\main\\resources\\file.pdf&quot;;
      System.out.println(&quot;Read with local file: &quot; + localFilePath);
  
  
      try {
          File rawImage = new File(localFilePath);
          byte[] localImageBytes = Files.readAllBytes(rawImage.toPath());
  
          // Cast Computer Vision to its implementation to expose the required methods
          ComputerVisionImpl vision = (ComputerVisionImpl) client.computerVision();
  
          // Read in remote image and response header
          ReadInStreamHeaders responseHeader =
                  vision.readInStreamWithServiceResponseAsync(localImageBytes, null, null)
                      .toBlocking()
                      .single()
                      .headers();
     
          String operationLocation = responseHeader.operationLocation();
          System.out.println(&quot;Operation Location:&quot; + operationLocation);
  
          getAndPrintReadResult(vision, operationLocation);
  
      } catch (Exception e) {
          System.out.println(e.getMessage());
          e.printStackTrace();
      }
  }
  /**
   * Polls for Read result and prints results to console
   * @param vision Computer Vision instance
   * @return operationLocation returned in the POST Read response header
   */
  private static void getAndPrintReadResult(ComputerVision vision, String operationLocation) throws InterruptedException {
      System.out.println(&quot;Polling for Read results ...&quot;);
  
      // Extract OperationId from Operation Location
      String operationId = extractOperationIdFromOpLocation(operationLocation);
  
      boolean pollForResult = true;
      ReadOperationResult readResults = null;
  
      while (pollForResult) {
          // Poll for result every second
          Thread.sleep(1000);
          readResults = vision.getReadResult(UUID.fromString(operationId));
  
          // The results will no longer be null when the service has finished processing the request.
          if (readResults != null) {
              // Get request status
              OperationStatusCodes status = readResults.status();
  
              if (status == OperationStatusCodes.FAILED || status == OperationStatusCodes.SUCCEEDED) {
                  pollForResult = false;
              }
          }
      }
    
      // Print read results, page per page
      for (ReadResult pageResult : readResults.analyzeResult().readResults()) {
          System.out.println(&quot;&quot;);
          System.out.println(&quot;Printing Read results for page &quot; + pageResult.page());
          StringBuilder builder = new StringBuilder();
  
          for (Line line : pageResult.lines()) {
              builder.append(line.text());
              builder.append(&quot;\n&quot;);
          }
  
          System.out.println(builder.toString());
      }
  }
  
  
  //The error marks it in this method since it cannot extract the operation id
  
  
   /**
   * Extracts the OperationId from a Operation-Location returned by the POST Read operation
   * @param operationLocation
   * @return operationId
   */
  private static String extractOperationIdFromOpLocation(String operationLocation) {
      if (operationLocation != null &amp;&amp; !operationLocation.isEmpty()) {
          String[] splits = operationLocation.split(&quot;/&quot;);
  
          if (splits != null &amp;&amp; splits.length &gt; 0) {
              return splits[splits.length - 1];
          }
      }
      throw new IllegalStateException(&quot;Something went wrong: Couldn't extract the operation id from the operation location&quot;);
  }
    
  </code></pre>
  <p>I would appreciate if you could help me see what my mistake is or what I am doing wrong.</p>