1

Please let me know how I can post a quote to XTRF using REST API. We are having POST/quote functionality in REST API, but I am unable to find what are the params that we need to pass to that API call and I am getting Http status 415 - Unsupported Media type.

Please help me if anybody knows how to add Quote in XTRF using REST API

  • I get 404 at both POST/quote and POST/quotes. Quote creation is not docummented at https://demo.s.xtrf.eu/api/doc/users/pages/quotes.html#GET_/quotes/{quoteId} – milkovsky Feb 29 '16 at 11:53
  • To clarify, are you trying to create smart or classic quotes? – HaPsantran Jan 22 '18 at 21:37

2 Answers2

0

XTRF REST API method POST /quotes expects JSON formatted content. It responds with HTTP status code 415 (Unsupported Media type) if the content does not conform to the JSON format (i.e. uses different format or there are some syntax errors in JSON string).

Example content might look as follows:

{
  "name" : "Google Gloves",
  "customerProjectNumber" : "G-312-2012",
  "workflow" : { "name" : "TP" },
  "specialization" : { "name" : "Economy"},
  "sourceLanguage" : {"name" : "English"},
  "targetLanguages" : [ {"name" : "Polish"}, {"name" : "German"} ],
  "deliveryDate" : "2012-09-15 11:30:00",
  "notes" : "Sample notes",
  "autoAccept" : false,
  "priceProfile" : {"name" : "Euro [€]"},
  "persons" : [{"id": 10}, {"id": 12}],
  "files" : [{"id": 1415596305}, {"id": 2005194325}],
  "referenceFiles" : [{"id": 4129771301}]
}

Tip: If you are using API from JavaScript you can use JSON.stringify function to ensure your object is properly serialized to JSON formatted string.

0

I am able to create a quote using the following CURL operation. Hope this will help.

$data =  '{
    "name" : "Test Estimate Newest",
    "customerProjectNumber" : "Test Project XX",
    "workflow" : { "name" : "Edit" },
    "specialization" : { "name" : "Economy"},
    "sourceLanguage" : {"name" : "English"},
    "targetLanguages" : [ {"name" : "Polish"}, {"name" : "German"} ],
    "notes" : "Sample notes",
    "autoAccept" : false,
    "persons" : [{"id":"131"}],
    "files" : [],
    "referenceFiles" : []
    }'; 
$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'Your URL to XTRF');
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiepath);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json', 'Content-Length: '. strlen($data))); 

    $result = curl_exec($ch);
    curl_close($ch);
    return $result;

-Vamsi