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

devrajsinghr
Active Participant
0 Kudos

I was wondering that Initially you had given the ref for API's for BTP account management which there are many endpoints for Account Management But Later you did not ask people to use API's to create the directory instead gave us GUI and CLI options to do that..

qmacro
Developer Advocate
Developer Advocate
0 Kudos

That's right. If you re-read this part:

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.

you'll see that the idea for this task was to create something that you could, in a later task, use the APIs to access 👍

Ruthiel
Product and Topic Expert
Product and Topic Expert
0 Kudos

08762a01a5446922b1a2e7dc68ac24eb60474f2c29a4d77cf953780dfd12dbb1

devrajsinghr
Active Participant
0 Kudos

Hi @qmacro 

Good morning,

I was wondering to configure the BTP instance with the API hub and try the API section but clueless about the values to input so that the API hub can connect to our BTP instance.

 

Configure New EnvironmentConfigure New Environment

qmacro
Developer Advocate
Developer Advocate
0 Kudos

I like the curiosity! Which part of the documentation did you read for this? Was there information missing or unclear? Let us know, I'd be keen to find out and be able to feed that back.

lehuynhnam
Explorer
0 Kudos

074810ebf0c993b118fd3828711f694a81aad17648ad23e7aebc950830c519c3

sandeepmalhotra
Participant
0 Kudos

8cde2ec0f45564d7ca0fa2e5548e9ac743758203561b989137ee3a6f01545350

cguttikonda24
Participant
0 Kudos

3ff6dc46874c736517548cef51cefe0b601a680e5ac456053e99789ceff35288

adrian-ngo
Explorer
0 Kudos
a4f7325e3997843a6d38c80641f49018c90b56e9af4d3e2340089a7637a9adff

OlgenH
Participant
0 Kudos

f49df63407ae6139aa77f01abdd3320944d6c824293c7815e673315ff2e820bf

nex
Explorer
0 Kudos

ec14845a7e1bef8d3764809d8481f49a3b544c39ea55a6fbaee614795d9d7a9e

RafkeMagic
Active Contributor
0 Kudos

ffb8829ac83d41cac7949edc1b02a43a522bbb70f880439481b2481189fc3a51

flo_conrad
Explorer
0 Kudos

837d4fa810972b89bc6783b4b438c8139d94ad48f561d96ecda77240895b06db

RaulVega
Participant
0 Kudos

684dfbaba0fba7967f86b5929a48d677b409b30f155b23b2c34469366c46abba

SubaR
Explorer
0 Kudos

8ea766f99a56597ff5792a207b934da8b02b6af2be6bcda098796d3eba77b1f0

sainithesh21
Active Participant
0 Kudos

aabd2a2c706b5919bec1409ece62e452339b5f983c1cca76de9308ba6d99d6c1

satya-dev
Participant
0 Kudos

I created directory using BTP CLI, the length of GUID of created directory will be 36 always, but Hash value may differ why ? thinking🤔

3ccc348d5120445fafa56ac1e564f6aa592d6c72000dfd20c07e5c4e996ab0cc

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Good question! That's because I combine (in a secret way) your individual SAP Community ID with the value you send for hashing 🙂

qmacro
Developer Advocate
Developer Advocate
0 Kudos

Hey everyone! The challenge to which this task belongs is now officially closed. Head over to the original blog post SAP Developer Challenge – APIs to check out the closing info and final statistics, and to see your name in lights! 🎉  And we thank you all for participating, you made this challenge great!

buz
Explorer
0 Kudos

326edb4a5078bf9f04a4c58c261857fef36f6e1fc27855a79fbbafd6fabfc94b