Using PHP with guzzle I am attempting to post a new topic with file to the the Brightsapce API as per https://docs.valence.desire2learn.com/res/content.html#post--d2l-api-le-(version)-(orgUnitId)-content-modules-(moduleId)-structure-
Using guzzle streams I have built the request which looks like this.
--xxBOUNDARYxx
content-type: application/json
Content-Disposition: form-data; name=""
Content-Length: 223
{"Title":"Placeholder, Please Delete","ShortTitle":"","Type":1,"TopicType":1,"Url":"\/content\/enforced\/376743-TKS101_TRI-3_2014\/test.html","StartDate":null,"EndDate":null,"DueDate":null,"IsHidden":false,"IsLocked":false}
--xxBOUNDARYxx
content-type: text/html
Content-Disposition: form-data; name=""; filename="test.html"
Content-Length: 477
<!DOCTYPE html>
<!--
...
$multipart_mixed = [
[
'name' => "",
'headers' => [
'content-type' => "application/json",
],
'contents' => json_encode($contentObjectData->toArray())
],
[
'name' => "",
'headers' => [
'content-type' => mime_content_type($file),
'Content-Disposition' => "form-data; name=\"\"; filename=\"$fileName\""
],
'contents' => file_get_contents($file)
]
];
$headers = ['Content-Type' => 'multipart/mixed;boundary=xxBOUNDARYxx'];
$body = new MultipartStream($multipart_mixed, $boundary);
$uri = $this->valenceInstance->authenticateUri("/d2l/api/le/$this->le_version/$orgUnitId/content/modules/$moduleId/structure/?base64=false", "POST");
return new Request("POST", $uri, $headers, $body);
Everything looks to be working as per the documentation but I always receive a "Request has missing or invalid parameters" I cannot see what parameter I might be missing?
This was solved by capitalizing "content-type"