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 19: Line 19:
 
* The Header parameter of Content-Type is set to application/text
 
* 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 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 input 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 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"
 
* The output is beng redirected into the file "Generated.xml"

Revision as of 06: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 input 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.