Calling Web Services via Curl

From FMR Knowledge Base
Revision as of 06:54, 7 February 2023 by Plazarou (talk | contribs) (Use of Curl)
Jump to navigation Jump to search

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

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"

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