1. andy rubey
  2. PowerBuilder
  3. Tuesday, 16 August 2022 19:13 PM UTC

I am unable to call mFax with a local file as an attachment.  All I get is the coversheet.  I am able to attache a URL to a fax successfully(a url that points to a pdf or jpg, etc)

 

header-------
Authorization:password:?
Content-Type:application/json
Accept:*/*
Accept-Encoding:gzip, deflate, br
Connection:keep-alive

body-----------
{ "faxNumber":"13209236452", "coverPage":"true", "coverPageId":"2b32c543-7238-4ebc-9346-c1b3230e88c5", "attachments": "c:\\temp\\q.pdf"}

response header--------
HTTP/1.1 200 OK
Cache-Control: no-store
Connection: keep-alive
Date: Tue, 16 Aug 2022 18:31:28 GMT
Pragma: no-cache
Transfer-Encoding: chunked
Via: HTTP/1.1 m_proxy_chi
Via: HTTP/1.1 s_proxy_chi
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
ETag: W/"51f-rSiyEu1/BjMRIPvDlU3cKovqpvI"
Vary: Accept-Encoding
X-Powered-By: Express
Access-Control-Allow-Origin: *
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1660674746
X-Content-Type-Options: nosniff
Access-Control-Expose-Headers: Content-Disposition
X-Server-Version: 4.9.0
Strict-Transport-Security: max-age=31536000; includeSubDomains

Daryl Foster Accepted Answer Pending Moderation
  1. Thursday, 18 August 2022 02:16 AM UTC
  2. PowerBuilder
  3. # 1

Hi Andy,

Have you got the Powerbuilder code you are using?  Looking at the link to the documentation you provided https://docs.documo.com/#34a91cce-9cfa-421f-b04c-7a58bf29a712, the examples show attachments being sent when the api request is sent as 'multipart/form-data' rather than 'application/json'.

Have a search of this forum for multipart and there are a bunch of examples which show how to send multipart/form-data http requests.  It is pretty straightforward.  If you look at the examples for some of the other languages e.g C# and Http on the documo document page it should give you a good idea about what you are trying to achieve.  Here is part of the http message that you are after:

POST /v1/faxes HTTP/1.1
Host: api.documo.com
Authorization: Basic API_KEY
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Length: 1748

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="faxNumber"

11234567890
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="attachments"; filename="file"
Content-Type: <Content-Type header here>

(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="coverPage"

false
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="coverPageId"

d1077489-5ea1-4db1-9760-853f175e8288
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="tags"

 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 17 August 2022 14:00 PM UTC
  2. PowerBuilder
  3. # 2

Have you tried if it works when opening the file in streammode?

long ll_filetoload
blob lbl_filestream

ll_filetoload = fileopen("your file", streammode!, read!, lockwrite!)

filereadex(ll_filetoload, lbl_filestream)

fileclose(ll_filetoload)

Then you have to "submit" it the way nodejs does "submit" createReadStream result. I don't know if it will work. You can test it...


Andreas.

Comment
  1. Andreas Mykonios
  2. Wednesday, 17 August 2022 14:16 PM UTC
But it must be something more complicated. In java the provided example is:

.addFormDataPart("attachments","file",

RequestBody.create(MediaType.parse("application/octet-stream"),

new File("/path/to/file")))



Andreas.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 16 August 2022 19:54 PM UTC
  2. PowerBuilder
  3. # 3

The fax server isn't going to be able to access the local file "c:\\temp\\q.pdf". That is why it needs the URL pointing to a file on a web server.

Check their documentation to see if it has a way to embed the contents of the file in the message.

Also, \\ is used in C++ to indicate a single back-slash. In PB the escape character is ~ and in C++ it is \.

Comment
  1. Roland Smith
  2. Wednesday, 17 August 2022 14:04 PM UTC
Sorry, I don't. If you give a link to the docs, perhaps someone can figure it out.
  1. Helpful
  1. andy rubey
  2. Wednesday, 17 August 2022 16:16 PM UTC
  1. Helpful
  1. Roland Smith
  2. Wednesday, 17 August 2022 17:57 PM UTC
I think it would be easier to upload the files to your web server and passing the URL to the FAX service. Then when the FAX is complete, delete the file or moved it to a sent folder.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 16 August 2022 19:41 PM UTC
  2. PowerBuilder
  3. # 4

Hi, Andy - 

Is this a PowerBuilder problem or a Documo mFax problem? You may need to ask the vendor that supplies the REST API.

Just a guess: Try supplying the file's path and name in URL form. For example: "file:///C:/test.pdf".

Comment
  1. andy rubey
  2. Tuesday, 16 August 2022 20:00 PM UTC
Thx for the fast reply, I did try that and many other things to no avail. I think it is a developer problem and neither documo or appeon's problem!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.