Hi all,
First time poster here. I am a newly hired developer at my organisation (I do not have my own TW Community account at the time of writing, which is why I am writing from this account). Prior to my position at this organisation, I have no experience using either Indicium or Thinkwise as a platform so, my apologies if anything is at all unclear in this question.
Now for my actual issue: I am attempting to POST an encoded image file (most probably JPEGs from client side) to Indicium Basic. The image is quite small, usually no more than 500KB, yet with each requests a 400 Bad Request error is returned by Indicium. The full response is as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD>
<BODY>
<h2>Bad Request - Invalid Verb</h2>
<hr>
<p>HTTP Error 400. The request verb is invalid.</p>
</BODY>
</HTML>
Search results on StackOverflow and other sites about the response indicate either invalid cookies or cache in the browser getting in the way or, in case of a file upload, a restriction on file size.
I have tried deleting cookies and cache multiple times to no avail, and my colleagues are unaware of any file size restriction on either Indicium itself or the IIS instance on which it runs.
The request I am trying to send is as below:
{
"subsidiary_id": 1,
"branch_id": 3,
"work_order_id": 326,
"work_order_document_id": null,
"document": {
"FilePath": "test.jpg",
"FileName": "test.jpg",
"File": "<base64_encoded_file_string_here>"
},
"comment": "null",
"document_class_id": 38,
"insert_user": null,
"insert_timestamp": null,
"update_user": null,
"update_timestamp": null
}
If my colleague tries this same body in his Postman client, it creates the document without issue. However, soon as I try it in either my own Postman client or in the API, it returns the above Bad Request response.
Should it be of any help, below is the C# code in the API which makes the request to Indicium using the FlurlHttp library:
// <base_url>/sf/<application>/work_order_document
IFlurlRequest postDocument = _optionsMonitor.CurrentValue.GetUriToBranch()
.AppendPathSegment("work_order_document")
.WithBasicAuth(
_httpContextAccessor.HttpContext?.Items["dms-user"]?.ToString() ??
throw new UnauthorizedException("Username could not be found in the request.", null),
_httpContextAccessor.HttpContext?.Items["dms-pass"]?.ToString() ??
throw new UnauthorizedException("Password could not be found in the request", null));
try
{
IFlurlResponse response = await postDocument.PostJsonAsync(new
{
subsidiary_id = document.SubsidiaryId,
branch_id = document.BranchId,
work_order_id = document.WorkOrderId,
document = document.Document, // { FilePath: "test.jpg", FileName: "test.jpg", File: "<base64_encoded_file_string_here>" }
comment = document.Comment,
document_class_id = document.DocumentClassId
}, ct);
return response.ResponseMessage.IsSuccessStatusCode;
}
catch (FlurlHttpException e)
{
throw await HandleErrorAsync(e);
}
I am unsure where to go from here, none of the “common” problems I found seem to resolve this issue. Am I missing something in the request? Or should I specify some specific header for these types of requests?
Any help is greatly appreciated. If anything is at all vague or unclear, please do not hesitate to ask!
Many thanks in advance!