How to upload files to an item in php

Am trying to upload files to an item via php by it throws error internal server 500

Please can someone provide me with the right code

Here is my code


$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.monday.com/v2/file',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('query' => 'mutation ($file: File!, $item_id: Int!, $column_id: String!) { add_file_to_column ( item_id:$item_id, column_id: $column_id, file: $file) { id}}','variables' => '{"item_id":2267231528, "column_id": "files"}','map' => '{"image":"variables.file"}','image'=> new CURLFILE('https://cdn.pixabay.com/photo/2015/05/26/12/30/baby-784608_960_720.jpg')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: $token"
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Hi @fredo
There are multiple examples in the forum that show you at least where to start, see e.g. Search PHP Developer for Fileupload via Graphql API - #3 by basdebruin

2 Likes

Thanks alot @basdebruin. I appreciate

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.