CRUD ROOKIE - Update Object With API

Mission: CRUD ROOKIE
Task: Update Object With API

I’ve managed to get through “Update Object With API” and “Retrieve Object With API”

But now I am stuck on Updating Object
Shared with CloudApp

The above image comes from
curl -X “PUT” “https://api.backendless.com/70833ED6-CF55-DCA8-FFD1-0F4165255600/1F5AE496-3F41-40C2-8104-D4F29C062163/services/UpdateObject/updateObject
-H ‘Content-Type: application/json’
-H ‘Accept: application/json’

So, you can see I created a PUT REST Operation which I believe is correct but I don’t know what blocks to add to complete the service and get through the Mission.

Where should I go from here?

Hello @Kenny_Butler

you need to follow the instruction:

Congratulations! You have completed this task.

With this task you will update an existing object in the database using the Backendless Database API. In order for the task to be recognized as complete, an object must be updated in the Person table. If you work on the tasks in the same order as listed, you already have a few working programs. Continuing to expand them is the way to go! Below is a sample JS program which retrieves the first object from the database, updates a property and saves the object back:

const APP_ID = 'XXXXXXX-7252-9A9E-FFF3';
const API_KEY = 'XXXXXXX-4591-4886-9A54';
Backendless.initApp(APP_ID, API_KEY);

Backendless.Data.of('Person').findFirst()
  .then(function (object) {
    // update the object - assign a random value
    // to the "age" property
    object.age = Math.round( Math.random() * 50 );

    // now save the object back in the database
    Backendless.Data.of('Person').save(object)
      .then( function (savedObject) {
        console.log( 'Object has been updated' );
      })
      .catch(function (error) {
        console.log( 'Error updating object ' + 
                     error.message);
        throw error;
      });
  })
  .catch(function (error) {
    console.log( 'Error ' + error.message);
    throw error;
  });

After you run the program, you can verify the object has been updated in the database. This can be done by clicking the Data icon in Backendless console and selecting the Person table. Value for the age property should be different than in the original code which saved the object:

person object

just transform the code into Codeless blocks:

  • Get first object from table
  • Set property in
  • Save object in Backendless

Regards, Vlad

I’m still having trouble finding the blocks to use for what you listed to do:

  • Get first object from table
  • Set property in
  • Save object in Backendless

I used a PUT to create the API Service. Is this correct?:

curl -X “PUT” “https://api.backendless.com/70833ED6-CF55-DCA8-FFD1-0F4165255600/1F5AE496-3F41-40C2-8104-D4F29C062163/services/UpdateObject/updateObject
-H ‘Content-Type: application/json’
-H ‘Accept: application/json’

Unlike the Missions before Crud Rookie there are no instructions so I am learning as much as I can but I haven’t found anything that shows the Crud Rookie assignments exactly as they are asked.

Hi, @Kenny_Butler

You can find these blocks in the Data Api Section Monosnap
And Set property in block in the Object Section
Monosnap

As an alternative, you can complete this mission with any other kind of SDK that is supported in Backendless. I will leave you a link to the docs where you can find the information you need to complete this mission.

Regards,
Marina

I was able to complete all four Crud Rookie tasks. Thanks