I'm trying upload file to Google Drive by REST API guide (Metadata + Media) But receive a response error: "Media type 'multipart/related; boundary=foo_bar_baz' is not supported. Valid media types: [/]"
RESTResponseDataSetAdapter1->AutoUpdate = false;
RESTRequest1->Params->Clear();
RESTRequest1->ClearBody();
RESTRequest1->Resource = L"";
RESTRequest1->Method = rmPOST;
RESTClient1->BaseURL = L"https://www.googleapis.com/upload/drive/v3";
RESTRequest1->Resource = L"/files?uploadType=multipart";
RESTClient1->ContentType = L"multipart/related; boundary=foo_bar_baz";
UnicodeString Boundary = L"foo_bar_baz";
UnicodeString Body = L"";
RESTRequest1->Params->AddItem();
RESTRequest1->Params->Items[0]->Kind = pkHTTPHEADER;
RESTRequest1->Params->Items[0]->name = L"Content-Type";
RESTRequest1->Params->Items[0]->Value = L"multipart/related; boundary=" + Boundary;
// RESTRequest1->Params->Items[0]->Value = "application/json; charset=UTF-8";
// RESTRequest1->Params->AddItem();
// RESTRequest1->Params->Items[1]->Kind = pkHTTPHEADER;
// RESTRequest1->Params->Items[1]->name = L"Content-Length";
Body = (UnicodeString)sLineBreak + L"--" + Boundary + sLineBreak;
Body = Body + L"Content-Type: application/json; charset=UTF-8" + sLineBreak + sLineBreak;
Body = Body + L"{\"name\":\"test.json\"}" + sLineBreak + sLineBreak;
Body = Body + L"--" + Boundary + sLineBreak;
Body = Body + L"Content-Type: application/json" + sLineBreak + sLineBreak;
Body = Body + L"{\"test\":\"test\"}" + sLineBreak;
Body = Body + L"--" + Boundary + "--";
// RESTRequest1->Params->Items[1]->Value = IntToStr((__int64)Body.Length()*sizeof(Body));
RESTRequest1->AddBody(Body, TRESTContentType::ctMULTIPART_RELATED);