| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
CURL.GetResultAsText
Returns the result of the transaction as text.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "CURL.GetResultAsText"; curl { ; Encoding; preserveLineEndings } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| curl | The CURL session handle. | $curl | |
| Encoding | The text encoding for result. Default is native. This function can also handle UTF-16 as well as UTF-16LE and UTF-16BE for little/big endian byte order. Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ. |
"UTF-8" | Optional |
| preserveLineEndings | Whether to change line endings to CR for FileMaker. By default (0) we change the line endings to CR, so FileMaker has no trouble. Pass 1 to keep whatever line endings are there. |
0 | Optional |
Result
The result as text.
Description
Returns the result of the transaction as text.You are responsible for detecting decoding.
See also CURL.GetResultAsContainer.
Plugin version 5.2 and newer replace newlines automatically for you to match what FileMaker uses (Mac line endings).
Examples
Query result as UTF-8 text:
MBS("CURL.GetResultAsText"; $curl; "UTF-8")
Query result as Windows Ansi encoding:
MBS("CURL.GetResultAsText"; $curl; "windows")
Get result text and convert line endings for FileMaker:
Download some text:
Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; CURL Test::URL)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::Text; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; CURL Test::URL)]
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
Set Field [CURL Test::Text; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Download a text from URL:
# start new transfer
Set Variable [$curl; Value:MBS("CURL.New")]
# set URL
Set Variable [$r; Value:MBS("CURL.SetOptionURL"; $curl; "https://www.mbsplugins.eu/")]
# run transfer
Set Variable [$ErrorCode; Value:MBS("CURL.Perform"; $curl)]
# get result as text and debug messages:
Set Variable [$TextResult; Value:MBS( "CURL.GetResultAsText"; $curl)]
Set Variable [$DebugMessages; Value:MBS( "CURL.GetDebugMessages"; $curl)]
# cleanup
Set Variable [$r; Value:MBS("CURL.Release"; $curl)]
Set Variable [$curl; Value:MBS("CURL.New")]
# set URL
Set Variable [$r; Value:MBS("CURL.SetOptionURL"; $curl; "https://www.mbsplugins.eu/")]
# run transfer
Set Variable [$ErrorCode; Value:MBS("CURL.Perform"; $curl)]
# get result as text and debug messages:
Set Variable [$TextResult; Value:MBS( "CURL.GetResultAsText"; $curl)]
Set Variable [$DebugMessages; Value:MBS( "CURL.GetDebugMessages"; $curl)]
# cleanup
Set Variable [$r; Value:MBS("CURL.Release"; $curl)]
Query webservice with JSON request:
Set Variable [$curl; Value:MBS("CURL.New")]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "http://test.test/ws/v1/catalogo/getmodelos")]
#pass JSON for query
Set Variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; "{\"brandId\" : \"1\", \"device\" : \"70\"}"; "UTF-8")]
Set Field [models::result; MBS("CURL.Perform"; $curl)]
Set Field [models::text; MBS("CURL.GetResultAsText"; $curl;"UTF8")]
Set Field [models::header; MBS("CURL.GetDebugMessages"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "http://test.test/ws/v1/catalogo/getmodelos")]
#pass JSON for query
Set Variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; "{\"brandId\" : \"1\", \"device\" : \"70\"}"; "UTF-8")]
Set Field [models::result; MBS("CURL.Perform"; $curl)]
Set Field [models::text; MBS("CURL.GetResultAsText"; $curl;"UTF8")]
Set Field [models::header; MBS("CURL.GetDebugMessages"; $curl)]
Set Variable [$result; Value:MBS("CURL.Release"; $curl)]
Query list of emails via POP3:
# query list of emails
Set Variable [ $curl ; Value: MBS("CURL.New") ]
#
# setup pop3 server
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUseSSL"; $curl; 3) // required ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) // TLS v1.2 ]
#
# login
Set Variable [ $r ; Value: MBS("CURL.SetOptionUserName"; $curl; Postbox::Username) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionPassword"; $curl; Postbox::Password) ]
#
# list emails
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Variable [ $r ; Value: MBS("CURL.Release"; $curl) ]
#
Set Field [ Postbox::Log ; $debug ]
Set Field [ Postbox::Output ; $output ]
Set Variable [ $curl ; Value: MBS("CURL.New") ]
#
# setup pop3 server
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUseSSL"; $curl; 3) // required ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) // TLS v1.2 ]
#
# login
Set Variable [ $r ; Value: MBS("CURL.SetOptionUserName"; $curl; Postbox::Username) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionPassword"; $curl; Postbox::Password) ]
#
# list emails
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Variable [ $r ; Value: MBS("CURL.Release"; $curl) ]
#
Set Field [ Postbox::Log ; $debug ]
Set Field [ Postbox::Output ; $output ]
Get multiple emails via POP3 over the same connection by reusing it:
# query list of emails
Set Variable [ $curl ; Value: MBS("CURL.New") ]
#
# setup pop3 server
Set Variable [ $result ; Value: MBS("CURL.SetOptionUseSSL"; $curl; 3) // required ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) // TLS v1.2 ]
#
# login
Set Variable [ $r ; Value: MBS("CURL.SetOptionUserName"; $curl; IMAP Postbox::Username) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionPassword"; $curl; IMAP Postbox::Password) ]
#
# get first email
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/1") ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
#
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Field [ IMAP Postbox::Log ; $debug ]
Set Field [ IMAP Postbox::Output ; $output ]
#
# give you time to see it
Pause/Resume Script [ Indefinitely ]
# get second email, reuse same curl connection
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/2") ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
#
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Field [ IMAP Postbox::Log ; $debug ]
Set Field [ IMAP Postbox::Output ; $output ]
#
# give you time to see it
Pause/Resume Script [ Indefinitely ]
# get third email, reuse same curl connection
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/3") ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
#
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Field [ IMAP Postbox::Log ; $debug ]
Set Field [ IMAP Postbox::Output ; $output ]
#
Set Variable [ $r ; Value: MBS("CURL.Release"; $curl) ]
Set Variable [ $curl ; Value: MBS("CURL.New") ]
#
# setup pop3 server
Set Variable [ $result ; Value: MBS("CURL.SetOptionUseSSL"; $curl; 3) // required ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionSSLVersion"; $curl; 6) // TLS v1.2 ]
#
# login
Set Variable [ $r ; Value: MBS("CURL.SetOptionUserName"; $curl; IMAP Postbox::Username) ]
Set Variable [ $r ; Value: MBS("CURL.SetOptionPassword"; $curl; IMAP Postbox::Password) ]
#
# get first email
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/1") ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
#
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Field [ IMAP Postbox::Log ; $debug ]
Set Field [ IMAP Postbox::Output ; $output ]
#
# give you time to see it
Pause/Resume Script [ Indefinitely ]
# get second email, reuse same curl connection
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/2") ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
#
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Field [ IMAP Postbox::Log ; $debug ]
Set Field [ IMAP Postbox::Output ; $output ]
#
# give you time to see it
Pause/Resume Script [ Indefinitely ]
# get third email, reuse same curl connection
Set Variable [ $r ; Value: MBS("CURL.SetOptionURL"; $curl; "pop3://sslin.df.eu/3") ]
Set Variable [ $result ; Value: MBS("CURL.Perform"; $curl) ]
#
# We show results for debugging
Set Variable [ $output ; Value: MBS("CURL.GetResultAsText"; $curl) ]
Set Variable [ $debug ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Field [ IMAP Postbox::Log ; $debug ]
Set Field [ IMAP Postbox::Output ; $output ]
#
Set Variable [ $r ; Value: MBS("CURL.Release"; $curl) ]
See also
- CURL.GetDebugAsText
- CURL.GetHeaderAsText
- CURL.GetResultAsData
- CURL.GetResultAsJPEG
- CURL.GetResultAsPDF
- CURL.GetResultAsPNG
- CURL.SetupOAuth
- CURL.UseSystemCertificates
- JSON.GetPathItem
- Text.ReplaceNewLine
Release notes
- Version 12.3
- Fixed a possible race condition for CURL.GetResultAsText and similar.
- Version 9.3
- Added preserveLineEndings parameter for CURL.GetDebugAsText, CURL.GetHeaderAsText, CURL.GetInputAsText and CURL.GetResultAsText function.
Example Databases
- CURL/Amazon S3/Amazon S3 Upload File
- CURL/Amazon S3/Containers in S3
- CURL/CURL Check FileMaker Server
- CURL/CURL Download Text
- CURL/Email/List IMAP folders
- CURL/Email/Office 365 oAuth SMTP
- CURL/WebServices/CURL FMS Admin API v18
- CURL/WebServices/Google Maps API/Google Maps API
- CURL/WebServices/Swiss Post Addresscheck
- CURL/WebServices/Twitter oAuth
Blog Entries
- Using Gmail with oAuth2 for SMTP with MBS Plugin
- Send SMS with Amazon web service
- Using ChatGPT in FileMaker
- Adding ChatGPT to the ScriptWorkspace context menu
- MQTT in FileMaker
- Parallel network transfers with MBS Plugin
- How long do you wait for Insert From URL to finish?
- SFTP Upload with temporary file
- CURL Custom Function
- Trigger Scripts via WebHook
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 16th February 2023