Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a web service for uploading a file. In PHP this service can be called like this:
$url = $base_url . '/api/import';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'file' => '@'.dirname(__FILE__).'/filename',
));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data',
'Authorization: Bearer ' . $access_token,
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
In Drupal I would like to use wsclient, since I am using it for the rest of the service calls. But I don't see how this can be done.
Is there any way to do this with wsclient, or I should just use drupal_http_request()?