Skip to main content
added 18 characters in body; edited tags
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Want to use the API from this site. I'm having trouble using the same parameters.

But I can do this with curl as shown on the site:

curl 
  -F url=http://sbml.org/validator/api/sample-01.xml 
  -F output=xml 
  -F offcheck=u 
  http://sbml.org/validator/

But I can't get the same with Mathematica:

t1 = URLExecute@HTTPRequest["httpURLExecute @ HTTPRequest[
  "http://sbml.org/validator/",
   , <|"Method" -> "POST",
    , "Headers" -> {
       "Content-Type" -> "multipart/form-data;",
      , "Expect" -> ""},
     "MultipartElements" ->}
   , "MultipartElements" -> {
       {"name=\"url\";"} -> "http://sbml.org/validator/api/sample-01.xml"
       }
     |> 
, CharacterEncoding -> None
    ]; 

ImportString[StringJoin[t1], "XHTML"]

OUTPUT

File : null
Options :
Units consistency checking: on Identifier consistency checking: on \
MathML consistency checking: on SBO consistency checking: on \
Overdetermined model checking: on Modeling practices checking: on \
Overall SBML consistency checking: on Remove unrecognized packages: \
on Results: No model was given or it could not be resolved.

Want to use the API from this site. I'm having trouble using the same parameters.

But I can do this with curl as shown on the site:

curl -F url=http://sbml.org/validator/api/sample-01.xml -F output=xml -F offcheck=u http://sbml.org/validator/

But I can't get the same with Mathematica:

t1 = URLExecute@HTTPRequest["http://sbml.org/validator/",
    <|"Method" -> "POST",
     "Headers" -> {
       "Content-Type" -> "multipart/form-data;",
       "Expect" -> ""},
     "MultipartElements" ->
      {
       {"name=\"url\";"} -> "http://sbml.org/validator/api/sample-01.xml"
       }
     |>, CharacterEncoding -> None
    ];
ImportString[StringJoin[t1], "XHTML"]

OUTPUT

File : null
Options :
Units consistency checking: on Identifier consistency checking: on \
MathML consistency checking: on SBO consistency checking: on \
Overdetermined model checking: on Modeling practices checking: on \
Overall SBML consistency checking: on Remove unrecognized packages: \
on Results: No model was given or it could not be resolved.

Want to use the API from this site. I'm having trouble using the same parameters.

But I can do this with curl as shown on the site:

curl 
  -F url=http://sbml.org/validator/api/sample-01.xml 
  -F output=xml 
  -F offcheck=u 
  http://sbml.org/validator/

But I can't get the same with Mathematica:

t1 = URLExecute @ HTTPRequest[
  "http://sbml.org/validator/"
, <|"Method" -> "POST"
  , "Headers" -> {
      "Content-Type" -> "multipart/form-data;"
    , "Expect" -> ""
    }
  , "MultipartElements" -> {
      {"name=\"url\";"} -> "http://sbml.org/validator/api/sample-01.xml"}
  |> 
, CharacterEncoding -> None
]; 

ImportString[StringJoin[t1], "XHTML"]

OUTPUT

File : null
Options :
Units consistency checking: on Identifier consistency checking: on \
MathML consistency checking: on SBO consistency checking: on \
Overdetermined model checking: on Modeling practices checking: on \
Overall SBML consistency checking: on Remove unrecognized packages: \
on Results: No model was given or it could not be resolved.
Source Link

HTTPRequest with multiple parameters

Want to use the API from this site. I'm having trouble using the same parameters.

But I can do this with curl as shown on the site:

curl -F url=http://sbml.org/validator/api/sample-01.xml -F output=xml -F offcheck=u http://sbml.org/validator/

But I can't get the same with Mathematica:

t1 = URLExecute@HTTPRequest["http://sbml.org/validator/",
    <|"Method" -> "POST",
     "Headers" -> {
       "Content-Type" -> "multipart/form-data;",
       "Expect" -> ""},
     "MultipartElements" ->
      {
       {"name=\"url\";"} -> "http://sbml.org/validator/api/sample-01.xml"
       }
     |>, CharacterEncoding -> None
    ];
ImportString[StringJoin[t1], "XHTML"]

OUTPUT

File : null
Options :
Units consistency checking: on Identifier consistency checking: on \
MathML consistency checking: on SBO consistency checking: on \
Overdetermined model checking: on Modeling practices checking: on \
Overall SBML consistency checking: on Remove unrecognized packages: \
on Results: No model was given or it could not be resolved.