Jump to content
  • 0

Problem with updating Caspio using REST / PHP



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)


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_POSTFIELDS => $postdata,
        "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 comment
Share on other sites

4 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.





Link to comment
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).


Sonni T.

Link to comment
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 comment
Share on other sites

  • 0

Hi - Just want to share, I encountered the same issue but in my case, I used the GET method and it is working in Swagger, I was able to return records but when I used the URL on my third-party application, I get the 'IncorrectBodyParameter' error message and I just realized that I am copying the 'CURL' URL instead of the 'Request' URL. When I used the Request URL, it worked. 

This article might also help - https://howto.caspio.com/web-services-api/rest-api/error-handling/

Link to comment
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.

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.

  • Create New...