Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Developer Challenge - APIs - Task 7 - Create a new directory in an SAP BTP account

qmacro
Developer Advocate
Developer Advocate

(Check out the SAP Developer Challenge - APIs blog post for everything you need to know about the challenge to which this task relates!)

This task is the first in a group that belong together, and in it you will prepare the ground for the subsequent tasks in that group.

Background

The SAP Business Accelerator Hub contains API and related resources not only for SAP products such as SAP S/4HANA Cloud, SAP SuccessFactors, SAP Ariba, SAP Concur and so on, but also for the SAP Business Technology Platform, as you can see:

The Explore menu

Selecting this entry brings you to an overview page with links to APIs, events, integrations, business processes, workflow management resources and more. You'll see that one of the API packages available is Core Services for SAP BTP which contains multiple REST APIs, including:

  • Accounts Service
  • Entitlements Service
  • Events Service

and more.

These APIs afford you programmatic access to information on SAP BTP, specifically about your global accounts, subaccounts, directories, entitlements, services and lots more.

In the next few tasks you will take a small journey of discovery, one that will lead you to be able to make calls to these APIs, and in fact you will end up making a specific call to get a feel for how things operate and what you need to make such calls.

In order for everyone to have something consistent to work with, i.e. so that you all end up making essentially the same call, and will get the same results, this task will get you to create a directory in an SAP BTP account, with a custom label. In a subsequent task in this group you'll use the appropriate API in this Core Services for SAP BTP package to retrieve that information.

Your task

Your task here is to create a new directory within an SAP BTP global account accessible to you. If you don't have one, you can set up a trial account for free - see the "Hints and tips" section below for details.

Here are the task requirements:

  • The directory should be created at the top level of the account
  • It should be given the name developer-challenge
  • It should have one label named task with the value 7

You can do this any way you wish. You may want to use the SAP BTP Cockpit. You may wish to use the btp CLI. See the "Hints and tips" section below for both these approaches.

The value you need to get, to send to be hashed and shared in a reply to this discussion thread (as described, as always, in Task 0), is the length of the new directory's GUID. Not the GUID itself. The GUID consists of groups of hexadecimal digits interspersed with dashes. In calculating the length required, note that you should measure the length of the entire GUID, including the dashes.

Hints and tips

If you don't have a global account with which to work (for example, if you only have access to productive accounts at work and can't use them for learning), you can get a trial account on SAP BTP, and it won't cost you anything. You don't even need a credit card to sign up for one. Just follow the instructions in the tutorial Get a Free Account on SAP BTP Trial.

Creating the directory in the cockpit

You can create the directory from the Account Explorer section of the SAP BTP Cockpit.

Use the "Create -> Directory" menu from the button and specify the details appropriately, like this:

directory-creation.png

Once you've created the directory, it should look like this (you may have to adjust the display settings from the "tree view" to the "table view"). Note that the label information is available too in this display:

directory-created.png

Creating the directory with the btp CLI

Of course, as #TheFutureIsTerminal, you may prefer to go for maximum efficiency and use the command line. Luckily for us there's a great command line tool for accessing and manipulating resources on SAP BTP, and that's the btp CLI, available from the SAP Development Tools website. There are plenty of resources on the btp CLI, here are just a few:

Here's a sample session where I use the btp CLI to create the directory, in that I:

  • log on
  • choose an account (my trial global account)
  • use the create action for the appropriate group and object (accounts/directory)
# developer-challenge-apis/tasks/7-create-assets-in-an-sap-btp-account (main %=)
; btp login
SAP BTP command line interface (client v2.38.0)

CLI server URL [https://cpcli.cf.eu10.hana.ondemand.com]>
Connecting to CLI server at https://cpcli.cf.eu10.hana.ondemand.com...

User> dj.adams@sap.com
Password>

Authentication successful

Choose a global account:
  [1] c2d7b67atrial
  [2] ...
  [3] ...
Choose option> 1

Current target:
 c2d7b67atrial (global account, subdomain: c2d7b67atrial-ga)

We stored your configuration file at: /home/user/.config/btp/config.json

Tips:
    Commands are executed in the target, unless specified otherwise using a parameter. To change the target, use 'btp target'.
    To provide feedback about the btp CLI, use 'btp feedback' to open our survey.

OK

# developer-challenge-apis/tasks/7-create-assets-in-an-sap-btp-account (main %=)
; btp create accounts/directory \
  --display-name "developer-challenge" \
  --labels '{"task":[7]}'
Creating directory in global account 7da58aab-6c60-4492-a95b-b1ed3139e242...

directory id:         57675710-7b16-43ec-b64a-ab14660c1b24
display name:         developer-challenge
description:
directory features:   DEFAULT
created by:           dj.adams@sap.com
custom properties:    name:   value:
                      task    7
labels:               name:   value:
                      task    [7]
parent id:            7da58aab-6c60-4492-a95b-b1ed3139e242
parent type:          global account
state:                OK
state message:        Directory created.

Command runs in the background.
Use 'btp get accounts/directory' to verify status.

OK

Although the value 7 for the task label is scalar, it must be specified in the JSON value for the --labels parameter inside an array, i.e. [7] rather than just 7.

For discussion

Did you use the cockpit or the CLI tool? Which would or do you prefer? If you used the btp CLI, how did the installation go? Did you install it "natively" or did you use the script described in the SAP Tech Bytes: btp CLI – installation blog post?

What are some of your other power command line tools, inside the SAP ecosphere and also beyond?

99 REPLIES 99

MioYasuatke
Active Contributor
0 Kudos

c701b1a622820591d9e54ce8ecf45e2afaf48164adc89e46a4cfef1e5a5a70fc

vinaychowdary
Explorer
0 Kudos

84532529b670949e83b4a254a40f08f18628a1e1e17b4da132eedb361078420d

rajpbh1
Explorer
0 Kudos

Good explaination

govardhansahil
Explorer
0 Kudos

20acfa0a782921e540cf08a874c4ca2c3645b2b1aa2c2adf5925bf732539cad6

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

febb23c4e9c2e3d61f332aa9e6f40f5e912b527c5f85b1ab708d1d95279b4dbc




--------------
See all my blogs and connect with me on Twitter / LinkedIn

geek
Explorer
0 Kudos

28128b7a6a3ce46a48f8d633df7d3286178cfb774c7933017ce0fe921969222c

turanaydin
Explorer
0 Kudos

5bc9a996ced595486b22850a6161c55bdc024e1c99440b122dd88c63c4fe79c0

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

f42c43a48a5f671c6d3e825368aa54b84783c6079e4c634c233fc879a3748f2c

nmkarthikeya
Active Participant
0 Kudos

d6b3ed20a7aaacebcd8b5d79b3c3a60ff54a1aa04f2aa84aba4701c232602515

cdias
Product and Topic Expert
Product and Topic Expert
0 Kudos

214a9e99530d2bf4d727c93bce7bd5886e69b1da6bf1c99cdacf8bd20c1d25e5

SyambabuAllu
Contributor
0 Kudos

e88e20b26e98f972102dcbedc1368402b3f1f5f43ffd05c3775836fb133c5201

DazOwens
Explorer
0 Kudos

593ad02ddd69675ebb6cfb32f3064300dd6358eee6b03a41c3191c84a8585508

salilmehta01
Associate
Associate
0 Kudos

069407d14a1778522873ce97a81f5cea11ce155ee585a71660fef61cc8c61f49

szeteng00
Explorer
0 Kudos

7c9d33b6931024aaad689cfdb5c281ab26ac06ffaae835ba41debe41ca0fbc7a

Ritik
Participant
0 Kudos

c74242fdf9db2ded9ffeccbaedf368af1396193055bcbe0edb02c6f2c2fd5bc9

Nicolas
Active Contributor
0 Kudos

7409782ff89d0df3c379a2df36b750bd6c5d47617e2e67486262a7fb8e74f2f7

encarrero
Participant
0 Kudos

dda5ee7ded40d85c949562090f6d2ae281907dfae724fbf47cf11961b2942e21

Ashok459
Participant
0 Kudos

4d62474c57dc1e5e4c05bc99bf2bc02a8691ccdcf2f3778c7baf32ab42289603

johna69
Product and Topic Expert
Product and Topic Expert
0 Kudos

c92127d77c5bc18545bc499ef1ac397f615a3593ed73ffe8876e72c8c957ce84

Hey John,

hint, hint: don't put anything but the solution into the reply (see instructions in task 00)

Cheers, Uwe

johna69
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thanks, I should start at the beginning not the end....

qmacro
Developer Advocate
Developer Advocate

BTW, great to see you here @johna69 !

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

4e98a228b6e5450969ce4fd28262c081642d879ea6760c42090259bc5e8fb4ce

dhegde
Participant
0 Kudos

e4efb73f80a6d8ce6645e0cf10226c5739e2cf4e1014a3fcd0adf93ce6df553f

sabarna17
Contributor
0 Kudos

e9dcf5f968cf5c2ffa003ef70a2003393f074e16539fd5049836e21e7b56560e

tobiasz_h
Active Participant
0 Kudos

29c720e2b5655a7c5cd327724deb7c6939d6438fbc09d7e3d1b3cbfb4c74dd02

Frank_Haschick
Explorer
0 Kudos

7d6ad63db026c2c0de5281b2e9510dbf3601b6cff8ad1b83944a1945c54e911a

garyzuo
Explorer
0 Kudos

b5e650f72a4f0073ee182b489a8e3091fc74a43de876e1e0eddace1cacd72824

yassine
Explorer
0 Kudos

0a2a255d634e3295d4f9887874bcbe166b5e7913176c23f0f61a9a2ec97e3281

ibibhu
Product and Topic Expert
Product and Topic Expert
0 Kudos

ae92a3024f2cf6b579347308bab26bba4ae9f8f207c4b0a317d160f2a3208c8b

former_member136915
Product and Topic Expert
Product and Topic Expert
0 Kudos
79b3a9e3aa645ee84cbef5dc524899e069aa5fce42a42b2dc762896e8334b26b

tly
Explorer
0 Kudos

29f6b1cfa9c062ce3c5d0c5fc7a56e5ab749606afd8d6f242786bc05aef8d9aa

emiliocampo
Explorer
0 Kudos

65ac835332c8a5daeae2519a30a81ee88e4f79eb8f3e436f17375803e0c95209

ecem_yalim
Explorer
0 Kudos

fd7f537a8a527f9e0acad59111ffb63e954e5477b921cdfd493cc1ee5cf75732

ajos
Explorer
0 Kudos

972349e61258d7ecc4fb2a7617d853363d754a9e03721c9e139afbc8ab867805

0 Kudos

I did not use BTP cli. I have used it in the past to deploy app but did not feel like using it for this simple task.

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Fair enough! 🙂

andyl
Explorer
0 Kudos

c1f79fe27d7c56771a3f21263d3d898f37bcb37b704ce2bdb0427158e06a0c0d

andrew_chiam
Explorer
0 Kudos

1accab0e79bf7c30e61726eb3f64308ea00ce20ee45135d85924bd362d9b0493

devrajsinghr
Active Participant
0 Kudos

5a108f9e406fdeca05947c9537d197568f3be81fbb4574370b318fffbfa585c1