question

Julio Toledo avatar image
Julio Toledo asked Julio Toledo answered

Switching to -F/--form option for posting multipart/mixed forms?

My front-end development framework's cURL implementation requires all curl options be entered as raw text strings (text/plain). This is causing me all sorts of headaches with such things as posting multipart/mixed forms (i.e. FaxOut API requests).


For example, this works perfectly for me in Shell terminal but not in my front-end environment:

curl -X POST "https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax"; --header "Content-Type: multipart/mixed; boundary=Boundary_1_14413901_1361871080888" --header "Accept: application/json" --header "Authorization: Bearer {
                 {access_token}}" -d "--Boundary_1_14413901_1361871080888
Content-Type: application/json
{
                 
  \"to\":[{\"phoneNumber\":\"18005630003\"}],
  \"faxResolution\":\"High\",
  \"sendTime\":\"2013-02-26T09:31:20.882Z\"
}
--Boundary_1_14413901_1361871080888
Content-Type: text/plain
Hello, World!
--Boundary_1_14413901_1361871080888--"

When I try the same command from my front-end I get:

{  "message" : "Bad Request",
  "errors" : [ ]
}

The cURL http scripting docs recommend using "--form" commands for RFC1867 posting. If correct, can you provide some working examples for Faxing and MMS of how boundaries and content-types would be specified when using "-F" options?


P.S. Any other solution or workaround would be welcomed.










errors
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Julio Toledo avatar image
Julio Toledo answered
Hi Tyler,

PS. Just concluded my first test. Fax cover with cover text message went thru with no problems whatsoever.

The issue is apparently with the attachment file upload (whether it's text or binary). 

While I continue my debugging, any recommendations are welcome.


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Julio Toledo avatar image
Julio Toledo answered
Hi Tyler,

Please have a look at my most recent requests here and see if you can tell me what's going wrong:
http://mockbin.org/bin/a7f221dd-c4f1-465c-b62e-e066b9eb64c7/log

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Julio Toledo avatar image
Julio Toledo answered Julio Toledo commented
Ok, latest update is text/plain attachments are fine, but Hex encoded binaries (or Base64) do not.

So, this post body works:
{   "to":[{"phoneNumber":"13054081720"}],   "faxResolution":"High",   "sendTime":"2017-03-30T19:43:49.000Z",   "coverIndex":"11",   "coverPageText":"Hello world!" }
--------------------------34aa6472d5fa5bc8 Content-Disposition: form-data; name="attachment"; filename="filename.txt" Content-Type: text/plain  This is a test of the Emergency Broadcast System. The broadcasters of your area, in voluntary cooperation with federal, state and local authorities, have developed this system to keep you informed in the event of an emergency. If this had been an actual emergency, the Attention Signal you just heard would have been followed by official information, news, or instructions. --------------------------34aa6472d5fa5bc8-- 
However this post body does not work:

--------------------------df71a92203419cd5
Content-Disposition: form-data; name="request"; filename="json"
Content-Type: application/json { "to":[{"phoneNumber":"13054081720"}], "faxResolution":"High", "sendTime":"2017-03-30T19:48:44.000Z", "coverIndex":"11", "coverPageText":"Hello world!" }
--------------------------df71a92203419cd5
Content-Disposition: form-data; name="attachment"; filename="AddressLine.pdf"
Content-Type: application/pdf 255044462D312E340A25E2E3CFD30A312030206F626A0A3C3C0A2F4F504D20310A2F547970652F4578744753746174650A2F534D20302E3030310A2F4F5020747275650A3E3E0A656E646F626A0A322030206F626A0A3C3C0A2F46696C7465722F466C6174654465636F64650A2F4C656E677468203634350A3E3E0A73747265616D0A588585553D8FDB300CDDFD2B34268379A4BE051802724D52A06BBD355D0EC51568D10ED7FE7F94D6A79DB83864A1A947F2F189549E3E7E46F1FDCFF03C0F4F571224E6D7C180734620FF0C482394138404414931FF1A163732EEE730D1739C7F0C0E5C7239A109B4D65E50474FA817CC5D46AD21103BD6403A6D93198460B57837977160486F727D9948464D5FE74F8B798A1A8B798D8C92CB87819242380FE87510EBF8C3EDEF715439EA70FBDDEC094D2CB684E0A540317F5BDC97EA5EC3399FF705B2B8B99D5CFA5EDD80601B731F479F28B298A4A996205BFD6C13DBB53D1F49A97420C17BA373C082DFC8691558E9D7B526943B725A0FC659BFE5A46B6DBE13499D938BCE9A3B39031823C33AFE707B398EA45CD1A77F48907C1D4D44175728BE803DD44647A24A3CC9C8A5598942F9398E21512340C58795B2E111D0455F2E500E26BC2E5A20186F2BF6707B3D8EC1163E6FCD9E70C99D6C05E442930359A65C334F41C610EBC073BC6AB2E56C18C9AD848ED9CDC37E1E81C7D8C4AD483206B041911825A0E19D98CFF9F6645D001E1C959004DE9A7E91D7EAE72ACD2630967C53E385E73AB3CA6B50D40DC1AD87BC63B88B9233AFD343ACE2C595B6C5BEEDC6A6AEB35F32BEDD64BA9D86675557F9FFBB68C6826B134251AB22CB25D69108367455CE1D716A086F6D47F8E24EE988F2F06E026D47D41C6C069E429FD07D437963507BBB227910C7C7050DBCC886076AD34B6F0011A9D1FBD07930BDF2F4599E8DF5DA6803BABEC1B8F75873CF86DFBA8E4BEFEB983273C1B484B99E2ADEF4345480551D50BD08CB1BD369B6B0531CCBBD734FCD3C1780E269D33BABBC11D1A10AEBA670EF5F23683E47BF6D2A948ADC54E822AACEEE1C7D1EADCB3CFC03DB1B95E30A656E6473747265616D0A656E646F626A0A332030206F626A0A3C3C0A2F4E756D735B303C3C2F502831293E3E5D0A3E3E0A656E646F626A0A342030206F626A0A3C3C0A2F547970652F456E636F64696E670A2F446966666572656E6365735B322F636F6D6D6120342F706572696F642F7A65726F2F6F6E652F74776F2F74687265652F666F75722F666976652F7369782F736576656E2F65696768742F6E696E652F636F6C6F6E2F61742F412F422F452F462F482F492F4C2F4D2F4E2F4F2F502F532F542F552F582F756E64657273636F72655D0A2F42617365456E636F64696E672F4D6163526F6D616E456E636F64696E670A3E3E0A656E646F626A0A352030206F626A0A3C3C0A2F46696C7465722F466C6174654465636F64650A2F537562747970652F5479706531430A2F4C656E67746820323235330A2F4C656E6774683120323631360A3E3E0A73747265616D0A58855D556F5C54551ABE973B73AEF86784B9DE11D0EE19C0C50011316151F20F99F90768518965D1FEA08C0AA2A303897F324CD7C42673FD8B513F7193D422B7CC45FA475A9969192DFEC5BD6D2BA15D2DA7DD4D7FBEE7F2DE69F74C58BF7EFBE5BD77EE9C3FEF79FE1D51B08509A228DE5538AD307B7261F2A4C77DDECAAAB20A4FCAA4E5559EC5A59ED2826AAF20F23142368B14D820910D0E6377492CDA864BB169B07D78F73EBBD65BA07E7F4FED2BDF250862FFFEA1DA27225473235FE78FDE039C82248A2B9EAB9BE85DB2C257367F4195FBEEB989EEB4D199A3DDD9A5DE391EF7CC1595559E4595EEA98BE77A7D4BBCBE922A4FE970B73BBBA2C23D2334BED23DC353E9F12DE35F7F69D35D56E92E71FB3CF3CBF85C9FA7D45DE52B29F52C2AF12D747BE7B91FF4CC29F35678DD3387BBB37F35E7E7A3B9E347FEF29137CA51108434A1BF30428817460BAAE01222851861B89024C409FD84A1428A304050844461901025440B0305A79021A40BA9C2046194102B24083404934DB85F2816DE1693448FB83B2C32AC5292A431529EB45E6A924E4B5DB645B6761BB3C7D8C7D8AF916AB28B9C27FF9107C9A9F2915E25BD9EC67B1DD0ECDF032FEAD0A48BDF05D8CD80F49D2B0087582581B25D5F423A8C9DB01FA3A8758D980FE17675C2C3DEB19A550D4DCC4B2EBFB32C9D3AF05E3F448890073609F25C608308B411079BBA4E671DBAD811301F0F48DD4360998ACEF1DE14CD8A2529E3F7839342A30CCE8BFBAF6B2C965CBFE845270D5EC41A15734EDD03451A4B275074AA0B722814CB9093D785459A954EB028EF1ECCA10EF8D1AFC3161D56E94EDE7477605260A072CBEC80496A4E79F908CDAA872DCC4FAEB4AE4EA30AF3C2CBEAC48295859AF51CAC62DBC82BE79E9A4A83B3ADD3AAD98B28C7A1EFD563FFA69D32844D3E306EB3B6595696776D3F70EC68CC29F9AB924B98A4593F92D0867BCCF10DE29EEE47A43D2E8827F02D5C817FE1153B68C48A670ADC86EB761C44F0636CC10FA0C58E94C06DBC6E77401B0778A0CEC6B48BEF19ACD990DE8361AA1989C30C1806FD74ECC7D6600CB10CEB11BB1959A65ACD9B086B6699A189EB74D8AD3FAD43B2EEBC608C354CD118A8DC7F05BE51BB88F2EA172FB56EBD34089A080C7DB7DC4DCB658C79A20C7FAFE12B0407D77CF02D4D7D8260F2D15C98A0C145021BF775808B76C9903EEA2D1CA3E17AA28CC2F89235390BE94658664ED4830DFC987CCB106D270D33C1904EC2932AA61DCBE07CC00D0245C72E431A85ED32A4155EE67CE00DCE476106A651732DCE5331DF5B8D051A2E2658E06D807C0A9932E4EF6F80020D161328D85F8DF99CB9D0A1BC3A1CD49DBA916930E047BAC5C63359C5F5AB774204247CEA87691462088C3DEBC758F7D2729C4595D72C1F4E5731FCD87DB04883774900A20E431205438622A4F5A86A584B945B9889036A30874E9631E2F44310ABC1D7E48B0B3BBFDC4737612149CAA89EA2612B516AD1B5F0CD13B425557698E3FC7B1876895703DDF901E9AA2B604670FCF38211F676FE3023EC9B8211017301A6102BCBBA6965B19B76FEEEC0DB3D7AF83E207DCFE72C48EC910844E92C5517EBBBCBA57A1748E42AA4D85907B98A2976FECBBACF5C60470781E3568D6AAD24B081A5DAB981907CFCD1AF3C748814AF5D3FF7196DBAFCD5E1C64E0A0ADA64074CE7AB9F0E299EDBF4278F76B2CF75EB7358C5AEE8C107F8F6B25F376D0D3DFF9A77EBD609332AD45508EF1D3A6CD09D678C5186291B591CF16F5914FC43850FC9E5A675D81B0754D5726EB089286730AEE630D869EAC35C44278BA058834F086CD9FE778802D7BCC67B76D24DB25271E3A5177643740CB8FEF011166B8804E3F2F2B1172D368ECA6D2D8DE0D2E03502897B9F4429BDB61C15CA3519F2810E855D704417CF19A6CD90CEB9CC137AB0FC33F25DE3765859AF41D20E58FBC2B93A3F3C140DF1F3AE63A98627088ECF2CC06174B2715886212777DED4E03801D79F67C7A5D6CCC7D8A7285EA8C2CC9A7173FC3832DAC106F7A0D412C2C18CBB039419879D218EF0B3601C7C96C8D9BB97935ED6F0FFA905F5B69FF30BDA38BF922E9E31CF4AF0AC0BC2093BC8D00E62F06C96592DF7C0BA4B873FEACEF3069771372F03951F58D459154B56EE86DE10FEC6161841E1190223DE588FE1D87BE5722CA14A052E806B2A8EACD80EB2B1772FC451F80B81B8BD95A92857ACC59154D96ABD849B558C6C7B1486684C2330A4AD0522E9193990FFEAC43A8DE33F0CE417B6EAEFC4BC2343BF296F63AA86B709A64E7918FBD1D9F2ECAD59E058A56D94953FA17DB56F29CA313DDD1ED4B9EFB8E918FCD4EB2D96C67B1D3BD10FB1B75F7E0D6651701358FFFC1A8CC0845C3F4EA3CA5BB0864D538D2602E185E7709186EF92448C9A8B49140D198B803E01AA0621DB41260CA8E359FD850C11D33EC0580DBF269327ACC95CC2A3A588DCB8DCD0A601B7DDDDE06A2AFD2903FC7BD87FFF29B2AD86C4B6BA0C6E2F99E0FBB8A63517F6C2423BA7719D6EF6FD854398A6E2D0F38F416EC8CE907BFE080CA5ECCD44EB903CA9720E466B788D6074E55FDB293B94283BA0BC873AA60424A6707346B1303D78268B8585AE257F177B2BE47673D61DB71333999B1D12B83E82112498CC2D8F095C224918D92AFA59AD84913656DB6AD572515CE5303EDB05B5BAB3C330FB18D921182FC1444E27387D10AF412381DF40C22E7880726EFA677D8833353C423065C9814EE8D3B603A6D39B44590E3BEA96A1BC891A7CB8FAE029DCA0E17C828F24CEC3D15810580147293C489473E078BD6A447CC9228CA3789CA0C373F00C7D9F471624ADFBF8463B34B65FD3C5665E20BB1386B44B7008CEAA973E343A5ADE289D396646F2F8E28AC3A734E6C4DFAAF74D19579E3408A7600C38211746F3985560322483230353519C9AFEBBD51B76D63FFFDC8B9B9FA77F833AFB38B272FAD2D69286D9FE68EC9F892E74647C3AE14273F3CB4D07E82652BA6FF9AB1D30FA1B9801533103FAF3751FC37198817371358C450DE6F1F5C927373FD7425CDCB9A7EFE4D2A3BA15E47773A76E75F2E432F5E02CE258B7CD5CB00D7DDB081CDA06E15BAC1FEA6498D147EB6D9FB3B1A66F385B36C0D4D4FF019AE815FC0A656E6473747265616D0A656E646F626A0A362030206F626A0A3C3C0A2F466F6E7446696C65332035203020520A2F417363656E74203732340A2F58486569676874203733320A2F547970652F466F6E7444657363726970746F720A2F5374656D56203139300A2F436170486569676874203732340A2F5374656D4820300A2F466F6E744E616D652F564A564147562B4575726F7374696C652D457874656E64656454776F0A2F466C616773203236323134380A2F466F6E7442426F785B2D323231202D323739203133323620313034325D0A2F44657363656E74202D3137380A2F4974616C6963416E676C6520300A3E3E0A656E646F626A0A372030206F626A0A3C3C0A2F466F6E7444657363726970746F722036203020520A2F456E636F64696E672034203020520A2F4E616D652F46310A2F547970652F466F6E740A2F537562747970652F54797065310A2F5769647468735B3438322030203438322039363420393634203936342039363420393634203936342039363420393634203936342039363420343832203830302031303132203130313220383634203833392031303432203239362037363520313333322031303837203130383720393339203938372038363420313034322031303132203530305D0A2F4C617374436861722033320A2F42617365466F6E742F564A564147562B4575726F7374696C652D457874656E64656454776F0A2F46697273744368617220320A3E3E0A656E646F626A0A382030206F626A0A3C3C0A2F547970652F50616765730A2F4B6964735B39203020525D0A2F436F756E7420310A3E3E0A656E646F626A0A392030206F626A0A3C3C0A2F436F6E74656E74732032203020520A2F4D65646961426F785B302030203135312E32203134345D0A2F5265736F75726365733C3C2F50726F635365745B2F5044462F546578745D2F466F6E743C3C2F46312037203020523E3E2F4578744753746174653C3C2F4753302031203020523E3E3E3E0A2F547970652F506167650A2F426C656564426F785B302030203135312E32203134345D0A2F43726F70426F785B302030203135312E32203134345D0A2F5472696D426F785B302030203135312E32203134345D0A2F506172656E742038203020520A3E3E0A656E646F626A0A31302030206F626A0A3C3C0A2F547970652F436174616C6F670A2F506167654C6162656C732033203020520A2F50616765732038203020520A3E3E0A656E646F626A0A31312030206F626A0A3C3C0A2F58507265737350726976617465282525446F63756D656E7450726F63657373436F6C6F72733A20426C61636B5C6E2525456E64436F6D6D656E7473290A2F4D6F6444617465283230303631323133303132303230290A2F43726561746F7228517561726B58507265737328522920372E3031290A2F50726F647563657228517561726B58507265737328522920372E3031290A2F4372656174696F6E44617465283230303631323133303132303230290A2F5469746C653C4645464630303443303036313030373930303646303037353030373430303230303033313E0A3E3E0A656E646F626A0A787265660A302031320A303030303030303030302036353533352066200A30303030303030303135203030303030206E200A30303030303030303738203030303030206E200A30303030303030373934203030303030206E200A30303030303030383333203030303030206E200A30303030303031303331203030303030206E200A30303030303033333836203030303030206E200A30303030303033363138203030303030206E200A30303030303033393136203030303030206E200A30303030303033393731203030303030206E200A30303030303034323037203030303030206E200A30303030303034323734203030303030206E200A747261696C65720A3C3C0A2F53697A652031320A2F526F6F74203130203020520A2F496E666F203131203020520A2F49445B3C32333730464442334341413830453134424344443938464341364134443338463E3C32333730464442334341413830453134424344443938464341364134443338463E5D0A3E3E0A7374617274787265660A343531390A2525454F460A
--------------------------df71a92203419cd5--

               
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Julio Toledo avatar image Julio Toledo commented ·


0 Likes 0 ·
Tyler Liu avatar image
Tyler Liu answered
I cannot access  http://mockbin.org/bin/a7f221dd-c4f1-465c-b62e-e066b9eb64c7/log

For security reasons, my development framework does not permit direct file access
Then it's the limitation of your environment instead of RingCentral. I have no idea of your environment but is sounds really weird. You can convert that file into base64 so I guess you still can access it via code.

I don't think RingCentral fax supports base64 or hex encoding. I recommend fixing your dev env. Ask the administrator to grant you file access permission. Or at least there should be a temp folder that your app can access.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Julio Toledo avatar image
Julio Toledo answered
Never mind Tyler, I finally figured it out. My apologies for all of the back and forth.

Problem solved, binary attachments do work in my environment! (yay)



I was misinterpreting my development framework's documentation regarding restrictions on direct file access.Turns out the issue was with my debugging methodology ( mockbin.org) and not with my development framework. 

So yes, direct file access via http methods (cURL) is restricted in my development framework, however  it is  not necessary to convert binaries to text (base64 or hex). I do not need to encode the binary in any way prior to posting.
I don't think RingCentral fax supports base64 or hex encoding. I recommend fixing your dev env. Ask the administrator to grant you file access permission. Or at least there should be a temp folder that your app can access
These security restrictions are architectural in nature, so they are not within our control. Turns out my development framework's temp folder equivalency is to use my application's database as the intermediary. After importing the external file into my app's database, I am free to post it by assigning that field's contents to a variable (i.e. @$my-binary).

I had tried the above technique numerous times with mockbin.org, but my bin would blow up each time I posted binary data. Because mockbin.org was accepting hex/base64 but not accepting binaries, I was misled into thinking this was somehow related to my direct file access restrictions. 
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys