Difference between revisions of "Calling Web Services via Curl"

From FMR Knowledge Base
Jump to navigation Jump to search
(Use of Curl)
(Use of Curl)
Line 3: Line 3:
 
== Use of Curl ==
 
== Use of Curl ==
  
An example showing a call to transform an SDMX-CSV input file "My Input File.csv" into SDMX-ML version 2.1.  The output is redirected into the output file "Generated.xml"
+
The following shows an example use of curl to the Fusion Metadata Registry.
  
 
<pre>
 
<pre>
 
   curl -X POST  
 
   curl -X POST  
 
     --header "Content-Type:application/text"  
 
     --header "Content-Type:application/text"  
 +
    --header "Accept: application/vnd.sdmx.structurespecificdata+xml;version=2.1"
 
     --header "Structure:urn:sdmx:org.sdmx.infomodel.datastructure.Dataflow=OECD:DF_BATIS_EBOPS2010(1.0)"  
 
     --header "Structure:urn:sdmx:org.sdmx.infomodel.datastructure.Dataflow=OECD:DF_BATIS_EBOPS2010(1.0)"  
 
     --data-binary "@My Input File.csv"  
 
     --data-binary "@My Input File.csv"  
    --header "Accept: application/vnd.sdmx.structurespecificdata+xml;version=2.1"
 
 
     http://localhost:8080/FusionRegistry/ws/public/data/transform  
 
     http://localhost:8080/FusionRegistry/ws/public/data/transform  
 
     > Generated.xml
 
     > Generated.xml
 
</pre>
 
</pre>
 +
 +
The above specifies:
 +
* a POST command is being performed
 +
* The Header parameter of Content-Type is set to application/text
 +
* The Header parameter of "Accept is set to output in SDMX-ML Structure Specific 2.1 form
 +
* The inout file is an SDMX-CSV input file called "My Input File.csv"
 +
* The Registry is accessible at:  http://localhost:8080/FusionRegistry  and the transform Web Service is : /ws/public/data/transform
 +
* The output is beng redirected into the file "Generated.xml"
 +
  
 
=== Use of data-binary ===
 
=== Use of data-binary ===
 
It is highly recommended to specify your file with the "--data-binary" option.  Curl's -d option will strip out newline characters so is fine when validating / transforming XML but not for when you are processing CSV or Microsoft Excel files.
 
It is highly recommended to specify your file with the "--data-binary" option.  Curl's -d option will strip out newline characters so is fine when validating / transforming XML but not for when you are processing CSV or Microsoft Excel files.

Revision as of 05:57, 7 February 2023

Rather than using the Graphical User Interface, the Fusion Metadata Registry can perform operations by calling its Web Services. Examples of these are the Data Validation and Data Transformation Web Services. These can be invoked by a tool such as Postman, but this page aims to give some guidance on using the UNIX tool "curl" to invoke these Web Services.

Use of Curl

The following shows an example use of curl to the Fusion Metadata Registry.

  curl -X POST 
    --header "Content-Type:application/text" 
    --header "Accept: application/vnd.sdmx.structurespecificdata+xml;version=2.1" 
    --header "Structure:urn:sdmx:org.sdmx.infomodel.datastructure.Dataflow=OECD:DF_BATIS_EBOPS2010(1.0)" 
    --data-binary "@My Input File.csv" 
    http://localhost:8080/FusionRegistry/ws/public/data/transform 
    > Generated.xml

The above specifies:

  • a POST command is being performed
  • The Header parameter of Content-Type is set to application/text
  • The Header parameter of "Accept is set to output in SDMX-ML Structure Specific 2.1 form
  • The inout file is an SDMX-CSV input file called "My Input File.csv"
  • The Registry is accessible at: http://localhost:8080/FusionRegistry and the transform Web Service is : /ws/public/data/transform
  • The output is beng redirected into the file "Generated.xml"


Use of data-binary

It is highly recommended to specify your file with the "--data-binary" option. Curl's -d option will strip out newline characters so is fine when validating / transforming XML but not for when you are processing CSV or Microsoft Excel files.