Hi
Iam using OMR Api v5.1, but I have problem when send image to recognize.
I pass the filled template as base64 and the omr file (which in the genarate response) as base64
but I got error response
{
“type”: “RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content”,
“title”: “Unsupported Media Type”,
“status”: 415,
“traceId”: “00-7e3ca791866c8a07df9e8d3c676fff7c-e8e8755305d9bf97-00”
}
@mzfr.rgab98
The error message you are encountering, “Unsupported Media Type” with a status code of 415, typically indicates that the server is rejecting the request due to an issue with the content type of the data being sent. Here are some steps you can take to troubleshoot and resolve this issue when using the OMR API:
-
Check Content-Type Header: Ensure that you are setting the correct Content-Type
header in your request. For base64 encoded data, it should generally be set to application/json
.
-
Verify Base64 Encoding: Make sure that the images you are sending (both the filled template and the OMR file) are correctly base64 encoded. Any issues in the encoding process can lead to the server not recognizing the data format.
-
Review API Documentation: Double-check the API documentation to ensure that you are following the correct format for the request body. The structure should match what the API expects, including the correct fields and their types.
-
Example Code: Here is a simplified example of how to structure your request in C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public class OMRRecognition
{
private static readonly HttpClient client = new HttpClient();
public async Task RecognizeTemplate(string imageBase64, string omrFileBase64)
{
var task = new
{
images = new List<string> { imageBase64 },
omrFile = omrFileBase64,
recognitionThreshold = 30
};
var json = Newtonsoft.Json.JsonConvert.SerializeObject(task);
var content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var response = await client.PostAsync("YOUR_OMR_API_URL", content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
-
Testing with Known Good Data: If possible, test your implementation with a known good image and OMR file to ensure that the issue is not with the specific files you are using.
If you continue to experience issues, consider reaching out to the support team with details of your request and the exact data you are sending for further assistance.
Feel free to ask if you have any more questions or need further clarification!
Iam sure about my passed data (omrFileBase64,imageBase64 )
Can you provide me full workflow and base64 files to test it.
Iam using api v5.1
@mzfr.rgab98
We have responded to you in other thread where you have posted similar inquiry. We will be informing you as soon as some progress is made towards issue investigation. Please spare us some time.
We are sorry for the inconvenience.