Share ideas, ask questions, and get feedback about developing for ProcessMaker

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
#784318
Hi,
I need some help with uploading a document as input document via API as described in the PHP example at this link: http://wiki.processmaker.com/REST_API_C ... t-document

No matter what I'm doing, I keep getting the error: 400, Bad Request: This filename does not exist!.
When looking into the PM classes seems like the $_FILES is always empty. I'm new to APIs, I have no idea how debug further.

Please, let me know if anyone managed to use that piece of code to post an input-document (from another machine).

regards,
/d.
#785657
Hi Amosbatto,

I'm using asp.net for saving file and passing path as parameter.
like:-
{
"inp_doc_uid":"test10111124322509756bc1b5test10",
"tas_uid": "24322509756bc1b5012c202012716621",
"app_doc_comment": "test",
"form":"workflow/public_html/test.txt"
}

Response:- "message": "Bad Request: This filename does not exist!"

Can you suggest me ,what's the issue and how to solve? Please.....
Thanks
#785746
Hi,

I'm uploading file by using REST API while posting everything is fine but request status is 302 Found.
Please find attached Screen shot for API Request.
Post Data.png
Post Data.png (28 KiB) Viewed 2863 times
Post Data are below:-
--------------------------------------------------------------------------------------------
-----------------------------71042153412624
Content-Disposition: form-data; name="0"; filename="Capture.PNG"
Content-Type: image/png

‰PNG

���
IHDR��A��c���ãÕÓ���sRGB�®Îé���gAMA��±üa���
-----------------------------71042153412624
Content-Disposition: form-data; name="inp_doc_uid"

test10111124322509756bc1b5test10
-----------------------------71042153412624
Content-Disposition: form-data; name="tas_uid"

24322509756bc1b5012c202012716621
-----------------------------71042153412624
Content-Disposition: form-data; name="app_doc_comment"

test
-----------------------------71042153412624--

---------------------------------------------------------------------------------------------
After That i'm not receiving any Response
& Request Status 302 Found.
Can anyone help in that?

Thanks You
#795722
FelipeSolis wrote:Hi, I'm facing this problem with .NET too. API always return file does not exist. I would like to know if there is another way to upload the file input
Are you trying to use a web uploader like this or are you trying to run a script which uploads a file which already exists on the computer? Post your code. I don't know anything about .NET, but maybe I can spot something if I look at your code.
#824648
You can upload documents by using MultipartFormDataContent in C#. This was all done in ASP.Net Core, but it should work for some of the older .Net MVC versions as well.
Code: Select all
public async Task<ActionResult<JObject>> UploadFile()
{
        using (HttpClient client = new HttpClient())
        using (var formData = new MultipartFormDataContent())
        {
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",  authToken);

            formData.Add(new StringContent(documentUid), "inp_doc_uid");
            formData.Add(new StringContent(taskUid), "tas_uid");
            formData.Add(new StringContent(documentComment), "app_doc_comment");

            string filePath = Path.GetFullPath("/path/to/file.jpg");
            FileStream fileStream = new FileStream(filePath, FileMode.Open);

            formData.Add(new StreamContent(fileStream), "form", "file.jpg");

            HttpResponseMessage response = await client.PostAsync("https://example.com/api/1.0/workspace/cases/{caseId}/input-document", formData);

            string responseString = await response.Content.ReadAsStringAsync();

            JObject responseJson = JObject.Parse(responseString);

            if (!response.IsSuccessStatusCode)
            {
                return StatusCode((int)response.StatusCode, responseString ?? response.ToString());
            }

            return Ok(responseJson);
        }
}
You can also check out this Stackoverflow answer if you need to work with the file bytes rather than the file stream. https://stackoverflow.com/a/19983672

Hello, I'm trying to make a HTML page in which a[…]

IOS PUSH Notification

Latest Mobileios.pem already get its SSL cert expi[…]

Enabling SQL Server in Windows

Nice. https://360digitmg.com/india/ethical-hacking[…]

PM 3.5.0 supports MySQL 5.7.X configurations with […]