Jump to content
  • 0

Problem with updating Caspio using REST / PHP


Question

Hi all

I am trying to update a view in Caspio that consists of 2 tables using PHP and the REST API - but i keep getting errors.

I am trying to update the view using the JSON below ($postdata)

{"PK_ID":"48,100","TestTable1_ProduktId":4,"TestTable1_TestTable1Id":43,"TestTable1_VilHaSMS":true,"TestTable2_DatoOprettet":"2019-03-19T10:49:37","TestTable2_TestTable1Id":43,"TestTable2_SMS_sendt":true}

and this php-script

$url = $this->resource_url . '/views/my-test-view/records';
$auth = 'Bearer my-test-token';
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => $postdata,
    CURLOPT_HTTPHEADER => array(
        "authorization:" . $auth,
        "cache-control: no-cache",
        "content-type: application/json",
        'Content-Length: ' . strlen($postdata)
    )
));

I keep getting this error:

Message":"Cannot perform operation because the body parameter is absent or invalid.

What am i doing wrong?

'Looking forward to hearing from any of you :-)

 

Sonni T.

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @SonniT,

I am pretty much sure that you receive an error because you have used PK_ID field as body parameter.

PK_ID is a system field which acts as a record index for Caspio Table. I am afraid that you cannot use this field in body parameters.

Try removing this parameter from body to resolve the issue.

Please provide us with fields Data type used in the table if you still encounter an issue after removing PK_ID.


Regards,

vitalikssssss 

 

 

Link to post
Share on other sites
  • 0

Thanx for your reply.

I tried removing the column you requested but it didn't work im affraid.

The column types are as follows

{"TestTable1_ProduktId (integer)":4,"TestTable1_TestTable1Id (autonumber)":43,"TestTable1_VilHaSMS (yes/no)":true,"TestTable2_DatoOprettet (date/time)":"2019-03-19T10:49:37","TestTable2_TestTable1Id (integer)":43,"TestTable2_SMS_sendt (yes/no)":true}

In the Swagger UI it has a q.where clause that i don't use in the php-script - might that pose a problem? If so - how do i use that? (sorry if the question might be a bit basic).

Regards,

Sonni T.

Link to post
Share on other sites
  • 0

I have resolved the issue.

Instead of trying to update the entire record i just update the specific field in question - and i have added the where-clause.

$postdata = "TestTable2_SMS_sendt":true} and '/views/' . $name . "/records?q.where=" . $columnname . "=" . $columnvalue;

'Hope this can help others :-)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...