Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendFaxMessage does not attach file. #16

Closed
grokify opened this issue Apr 16, 2018 · 5 comments
Closed

SendFaxMessage does not attach file. #16

grokify opened this issue Apr 16, 2018 · 5 comments

Comments

@grokify
Copy link
Owner

grokify commented Apr 16, 2018

Sending a fax file does not attach the file.

Investigation into client.prepareRequest seems that the Swagger generated client uses the file MIME part name and RingCentral needs attachment.

Here is a dump of the prepared request showing the part name file:

--cb6494d72287d5a1e0950e4a98470bb71518f959145c6f00fa79c97ce7a8
Content-Disposition: form-data; name="faxResolution"

High
--cb6494d72287d5a1e0950e4a98470bb71518f959145c6f00fa79c97ce7a8
Content-Disposition: form-data; name="to"

+16505550100
--cb6494d72287d5a1e0950e4a98470bb71518f959145c6f00fa79c97ce7a8
Content-Disposition: form-data; name="coverPageText"

Hello World!
--cb6494d72287d5a1e0950e4a98470bb71518f959145c6f00fa79c97ce7a8
Content-Disposition: form-data; name="file"; filename="test_file.pdf"
Content-Type: application/octet-stream

%????1.2
0000000016 00000 n                                              xref
0000000644 00000 n
0000000917 00000 n
0000001068 00000 n
0000001224 00000 n
0000001410 00000 n
0000001589 00000 n
0000001768 00000 n
0000002197 00000 n
0000002383 00000 n
0000002769 00000 n
0000003172 00000 n
0000003351 00000 n
0000000760 00000 n
0000000897 00000 n
stream36 /Filter /FlateDecode /Length 17 0 R >> a4fe8bd49a9dd0599b0b151>]
streamngth 355 /Filter /FlateDecode >> .71519 0.1192 0.1805 0.0722 0.9505 ] >> 
H?t??N?0D???=ڈn?q?$G?????7?!MR
?	")??gm?"UB???z<??s/??g@?7????,+?ژ
c#??ϣ????|              ʿ?\?K            ??b?M~'???f?6
                             ~5O?*??r.??5k?j?ܦ
                                              ?yA??EH?5Y??X,????j?J,?_gyc?\?{?~?????B9,$??7u?w?+P%Z??~????'??}5??????.?#?"Q"????"?F{h?^U?K?`
'?????`?=???{?֟i???"͢?q?MJL?u=)&%?        iyC???RK??ǔ??_?ŭ?F:~?7?G<sX3?xOq??y?????^0????                                                      #;?V'?6
0000000000 65535 f0010829095457)ent)r Windows)0 0 222 833 556 556 0 0 0 0 0 
0000003429 00000 n
0000003658 00000 n
%%EOFxref46c5ba4fe8bd49a9dd0599b0b151><d70f46c5ba4fe8bd49a9dd0599b0b151>]
--cb6494d72287d5a1e0950e4a98470bb71518f959145c6f00fa79c97ce7a8--

Here is the code from api_client.go showing a hardcoded "file" part name.

https://github.com/grokify/go-ringcentral/blob/master/client/api_client.go#L242

part, err := w.CreateFormFile("file", filepath.Base(fileName))

Here's the specification in the RingCentral API Explorer requiring attachment

https://developer.ringcentral.com/api-docs/latest/index.html#!#SendFaxMessage

screen shot 2018-04-16 at 2 50 09 pm

Workaround

The following change has been verified to work:

Change api_client.go line 242 to use "attachment".

I'll look into Swagger Codegen a bit more to resolve this issue.

gplusplus314 added a commit to gplusplus314/go-ringcentral that referenced this issue Apr 16, 2018
@gplusplus314
Copy link

If anyone else is in immediate need of a hot-fixed dependency and wants to save a little time, I applied the one-liner change and pushed it to a branch on my fork. Here's a copy/paste friendly snippet for Glide:

- package: github.com/grokify/go-ringcentral
  repo: https://github.com/gerryhernandez/go-ringcentral.git
  version: faxMimeHotfix

gplusplus314 added a commit to gplusplus314/go-ringcentral that referenced this issue Apr 18, 2018
@grokify
Copy link
Owner Author

grokify commented Apr 18, 2018

The following endpoints use multipart/form-data and should be verified to work. If they all work with "attachment", then we can change.

  • POST /restapi/v1.0/account/{accountId}/extension/{extensionId}/fax
  • POST /restapi/v1.0/glip/files
  • POST /restapi/v1.0/account/{accountId}/ivr-prompts
  • POST /restapi/v1.0/account/{accountId}/extension/{extensionId}/profile-image
  • PUT /restapi/v1.0/account/{accountId}/extension/{extensionId}/profile-image

@grokify grokify closed this as completed Apr 18, 2018
@grokify grokify reopened this Apr 18, 2018
gplusplus314 added a commit to gplusplus314/go-ringcentral that referenced this issue Apr 25, 2018
@grokify
Copy link
Owner Author

grokify commented Apr 28, 2018

This is a bit more tricky because different endpoints have different MIME part names. The profile-image endpoint needs the file to have the image name. Sending it using attachment results in the following error.

An enhancement to send the part name to client.prepareRequest is needed.

POST /restapi/v1.0/account/{accountId}/extension/{extensionId}/profile-image

Status: 400 Bad Request

{
  "errorCode" : "InvalidParameter",
  "message" : "Parameter [image] value is invalid",
  "errors" : [ {
    "errorCode" : "CMN-101",
    "message" : "Parameter [image] value is invalid",
    "parameterName" : "image"
  } ],
  "parameterName" : "image"
}

This is mentioned here:

It also seems like Swagger Codegen can only send one file per request.

@grokify
Copy link
Owner Author

grokify commented Jul 8, 2018

Opened issue for OpenAPI Generator. I posted how solving this for a single file could be done. Still need design for multiple files and multiple names.

@grokify
Copy link
Owner Author

grokify commented Jul 8, 2018

Closing this since it's been fixed on the master branch here. Should be remedied in future releases if openapi-generator PR is accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants