This is extract from my document regards a current project.
We have had to utilize the API scripts using curl on windows. Below is some notes and examples. Please feel frewe to e-mail if you have further questions.
Automation scripts
Overview.
These scripts where developed using the TDM API. And Curl interface. Examples of each type of curl interaction is detailed below.
Following variables used.
Variable name | Contains / Purpose |
%SEC_TOKEN% | Contains the generated security token. Returned by createtoken. |
%SERVER% | Contains the database server name. |
%SQLUSER% | MSSQL User name |
%SQLPW% | MSSQL Password |
%DB% | Database Name. |
%CON_PROF% | Connection Profile Name |
%PROJ_ID% | Project ID returned by create projects. |
%VERS_ID% | Version ID returned by create versions. |
%SCHEMA% | Schema name for database, used in register. |
Get security token
Overview
In order to perform any actions with the TDM API a security token is required from the system, so the first step must always be that to obtain a security token.
The authorization is taken from the standard user:password combination for TDM converted to Base43. (www.base64encode.org)
Code.
curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: basic YWRtaW5pc3RyYXRvcjptYXJtaXRl" "https://localhost:8443/TestDataManager/user/login"
This will return a token that should be saved for future use.
Create Connection Profile
Overview
You will need a connection profile in order to reach databases in order for TDM to connect and do work, this statement creates a connection profile.
Code.
curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"name\":\"%CON_PROF%\", \"description\":\"Connection profile for %DB%\", \"dbType\":\"sql server\", \"server\":\"%SERVER%\", \"port\":\"\", \"instance\":\"\", \"service\":\"\", \"database\":\"%DB%\", \"schema\":\"\", \"username\":\"%SQLUSER%\", \"password\":\"%SQLPW%\" }" "HTTPs://localhost:%TDMPORT%/TDMConnectionProfileService/api/ca/v1/connectionProfiles"
Create Project
Overview
We will need a new project this create it for us. This statement creates one.
Code.
curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" --data "{ \"description\": \"%DB% Data Generator\", \"inheritTables\": true, \"name\": \"%DB%\" }" https://localhost:8443/TDMProjectService/api/ca/v1/projects
This will give you a project number to use further on.
Create Version
Overview
We need a version to work against. This will generate one for us.
Code
curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"description\": \"%DB% Data Generator\", \"name\": \"0\" }" "https://localhost:8443/TDMProjectService/api/ca/v1/projects/%PROJ_ID%/versions"
This will give you an version ID for use further in.
Create Datapool
Overview
This will create for use a datapool. NB also created default data group and Data set, TDMDG & TDMDS respectively.
Code.
curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"description\": \"Clone of script ref data\", \"name\": \"%DB%\", \"projectId\": %PROJ_ID%, \"versionId\": %VERS_ID%}" https://localhost:8443/TDMGeneratorService/api/ca/v1/generators?projectId=%PROJ_ID%&versionId=%VERS_ID%
This will give you a datapool ID that you will need to use later.
Register Tables.
Overview
This step allows you to register a table into the Project/ version created above. Before you can run this you will need to create a JSON file to use as input.
Code.
To create JSON file. In following format.
{"objectType":"TABLE","schema":"%SCHEMA%","connectionProfileName":"%CON_PROF%","tableNames":["TABLE1, TABLE2"]}
E.G file is TABLE.json.
curl -X POST --insecure -H "Authorization: Bearer %SEC_TOKEN%" -H "Cache-Control: no-cache" -F "body=@d:/temp/ TABLE.json;type=application/json" "https://localhost:8443/TDMModelService/api/ca/v1/objects?projectId=%PROJ_ID%&versionId=%VERS_ID%"
This is a copy of a actual "live" batch file created for a customer TALK TALK.
It works by reading an input file to get required information, then storing ID's etc created as it runs through the multiple servers, databases and Tables.
NB 54 servers, 142 databases 8k Tables.
@echo off
REM ================================================================================================
REM Use TDM REST API to create a project and register files
REM
REM Parameters: None
REM ================================================================================================
REM ================================================================================================
REM Housekeeping: Set any global configurations here
setlocal EnableDelayedExpansion
REM Set to 0 to disable debug information and/or error information
set DEBUG=1
set DSP_ERR=1
if %DEBUG% NEQ 0 echo ========== START OF HOUSEKEEPING ==========
set SQLUSER=CA_TA_Admin
set SQLPW=ZNpUDQZpIzeu
set TDMPORT=8443
set HTTP=https
REM FLAG indicating that all processing should be skipped/stopped.
set STOP_WORLD=0
REM FLAG to skip all processing on Current Database.
set SKIP_CURR_DB=0
REM ================================================================================================
REM Main
REM ================================================================================================
:main_loop
if %DEBUG% NEQ 0 echo ========== MAIN LOOP ==========
if %DEBUG% NEQ 0 echo.
set OLDDB=XXNODATABASEXX
set TMP_SERV=SOMEVALUE
REM Description of fields in input file:
REM DBName, ServerName, Databases, Schema, Table name, Duplicated tables Finder, Load data location
REM 1 2 3 4 5 6 7
REM a b c d e f g
cls
for /f "tokens=1,2,3,4,5,6,7 delims=," %%a in (D:\TDM\Database_load\WorkDataInput_test.cfg) do (
set SERVER=%%b
set DB=%%c
set SCHEMA=%%d
set TABLE=%%e
set DUPLCATE=%%f
set FOLDER="%%g"
REM if there is more than 1 table, then further lines have "x" in them, because it assumes previous values
if "%%b" NEQ "x" (
set TMP_SERV=%%b
) else (
set SERVER=!TMP_SERV!
)
set CON_PROF=!SERVER! - !DB!
if %DEBUG% NEQ 0 (
echo.
echo ==================================================
echo debug stuff
echo PPb: %%b
echo Temp Server: !TMP_SERV!
echo Server: !SERVER!
echo Connection Profile: !CON_PROF!
pause
)
REM echo.
REM echo ====================================
REM echo DB=!DB!
REM echo SERVER=!SERVER!
REM echo FOLDER="!FOLDER!"
REM echo TABLE=!TABLE!
REM echo SCHEMA=!SCHEMA!
REM echo ====================================
REM echo.
if "!OLDDB!" NEQ "!DB!" (
echo DATABASES HAVE CHANGED - New value is [!DB!] old value is [!OLDDB!]
set OLDDB=!DB!
echo.
echo ========================================================================
echo New Database being Processed: [!DB!]
echo ========================================================================
echo Current table: [!TABLE!]
echo Folder: [!FOLDER!]
echo ====================================
echo.
REM Clear error flag
set SKIP_CURR_DB=0
call :SUB_Setup_New_Project
if %SKIP_CURR_DB%==0 (
call :SUB_register_table
)
) else (
if %SKIP_CURR_DB%==0 (
echo.
echo ----------
echo Ongoing table processing for Database: [!DB!]
echo Register table: [!TABLE!]
echo.
echo FOLDER: [!FOLDER!]
echo ----------
echo.
REM type !FOLDER!
call :SUB_register_table
REM pause
)
)
)
REM goto end_fin
REM ================================================================================================
REM SUB-Routine Section
REM ================================================================================================
REM ==================
goto skip_subroutines
REM ==================
REM ================================================================================================
REM Setup new project
REM ================================================================================================
:SUB_Setup_New_Project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== Check if FOLDER/FILE exists ==========
if %DEBUG% NEQ 0 echo.
if not exist %FOLDER% (
set SKIP_CURR_DB=1
echo ========== Error: FOLDER/FILE does NOT exist ==========
echo Server entered: [%SERVER%]
echo Database entered: [%DB%]
echo full folder path: [%FOLDER%]
goto EXIT_SUB_setup_new_project
)
if %DEBUG% NEQ 0 pause
REM echo.
REM echo ========================================================================
REM echo In Setup New Project: [!DB!]
REM echo ========================================================================
REM echo Register table: [!TABLE!]
REM echo FOLDER: [!FOLDER!]
REM echo.
REM echo SERVER: %SERVER%
REM echo DB: %DB%
REM echo FOLDER: %FOLDER%
REM echo.
REM echo TABLE: %TABLE%
REM echo CONNECTION PROFILE: %CON_PROF%
REM echo ====================================
REM echo.
REM pause
REM ================================================================================================
:check_db
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF CHECK DB ==========
if %DEBUG% NEQ 0 echo.
REM Check that Database exists
Rem The database name supplied will be the project name used.
REM LIVE sqlcmd -S %SERVER% -U CA_TA_Admin -P ZNpUDQZpIzeu -d %DB% -s, -W -Q "exit"
sqlcmd -S %SERVER% -U %SQLUSER% -P %SQLPW% -d %DB% -s, -W -Q "exit"
if %errorlevel% NEQ 0 (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== NO SERVER / DB ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo.
echo No database server conbination present.
)
goto EXIT_SUB_setup_new_project
)
if %DEBUG% NEQ 0 pause
REM ================================================================================================
:get_token
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF GET TOKEN ==========
if %DEBUG% NEQ 0 echo.
del /Q /F zzz.txt
REM Use TDM REST API to acquire security token
echo.
echo Getting Token...
for /F "tokens=1 delims=," %%A in ('curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: basic YWRtaW5pc3RyYXRvcjptYXJtaXRl" "https://localhost:8443/TestDataManager/user/login"') do (
set part1=%%A
)
if %DEBUG% NEQ 0 (
echo Part1 is %part1%
)
if "%part1%"=="" (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== CURL ERROR WITH TOKEN ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo part1 error is %part1%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
echo.
echo Error Creating Token.
)
goto EXIT_SUB_setup_new_project
)
echo %part1% | find /c "status" > zzz.txt
set /p NUM= <zzz.txt
if %NUM% gtr 0 (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== HTML ERROR ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
echo.
echo HTML error received, detail is %part1%
)
goto EXIT_SUB_setup_new_project
)
REM extract just the token data from part1
for /F tokens^=4^ delims^=^" %%Z in ("%part1%") do (
REM echo %%Z
set SEC_TOKEN=%%Z
)
echo OUR TOKEN FOR THIS RUN IS %SEC_TOKEN%
if %DEBUG% NEQ 0 (
echo security token is %SEC_TOKEN%
)
if %DEBUG% NEQ 0 pause
REM ================================================================================================
:connection_profile
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF CONNECTION PROFILE ==========
if %DEBUG% NEQ 0 echo.
del /Q /F zzz.txt
REM Create Connection Profile
REM for /F "tokens=1 delims=," %%A in ('curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"name\":\"%CON_PROF%\", \"description\":\"Connection profile for %DB%\", \"dbType\":\"sql server\", \"server\":\"IREMA01-DMZ\", \"port\":\"\", \"instance\":\"SQLEXPRESS\", \"service\":\"\", \"database\":\"%DB%\", \"schema\":\"\", \"username\":\"%SQLUSER%\", \"password\":\"%SQLPW%\" }" "%HTTP%://irema01-dmz:%TDMPORT%/TDMConnectionProfileService/api/ca/v1/connectionProfiles"') do (
for /F "tokens=1 delims=," %%A in ('curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"name\":\"%CON_PROF%\", \"description\":\"Connection profile for %DB%\", \"dbType\":\"sql server\", \"server\":\"%SERVER%\", \"port\":\"\", \"instance\":\"\", \"service\":\"\", \"database\":\"%DB%\", \"schema\":\"\", \"username\":\"%SQLUSER%\", \"password\":\"%SQLPW%\" }" "%HTTP%://localhost:%TDMPORT%/TDMConnectionProfileService/api/ca/v1/connectionProfiles"') do (
set part1=%%A
)
REM Check for errors
echo %part1% | find /c "status" > zzz.txt
set /p RET_VAL= <zzz.txt
if %RET_VAL% gtr 0 (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== ERROR CREATING CONNECTION PROFILE ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo part1 error is %part1%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
echo.
echo echo Error Creating Connection Profile.
)
goto EXIT_SUB_setup_new_project
)
if %DEBUG% NEQ 0 pause
REM ================================================================================================
:create_project
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF CREATE PROJECT ==========
if %DEBUG% NEQ 0 echo.
del /Q /F zzz.txt
REM Create Project inside TDM
for /F "tokens=1 delims=," %%A in ('curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" --data "{ \"description\": \"%DB% Data Generator\", \"inheritTables\": true, \"name\": \"%DB%\" }" "https://localhost:8443/TDMProjectService/api/ca/v1/projects"') do (
set part1=%%A
)
REM Check for errors
echo %part1% | find /c "status" > zzz.txt
set /p RET_VAL= <zzz.txt
if %RET_VAL% gtr 0 (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== ERROR CREATING PROJECT ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo part1 error is %part1%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
echo.
echo Error Creating Project.
)
goto EXIT_SUB_setup_new_project
)
REM Get Project ID for created project
for /F tokens^=3^ delims^=:^" %%Z in ("%part1%") do (
set PROJ_ID=%%Z
)
echo Project ID generated is %PROJ_ID%
if %DEBUG% NEQ 0 (
echo Project ID: is %PROJ_ID%
)
if %DEBUG% NEQ 0 pause
REM ================================================================================================
:create_version
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF CREATE VERSION ==========
if %DEBUG% NEQ 0 echo.
del /Q /F zzz.txt
REM Create Version inside Project
for /F "tokens=1 delims=," %%A in ('curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"description\": \"%DB% Data Generator\", \"name\": \"0\" }" "https://localhost:8443/TDMProjectService/api/ca/v1/projects/%PROJ_ID%/versions"') do (
set part1=%%A
)
REM Check for errors
echo %part1% | find /c "status" > zzz.txt
set /p RET_VAL= <zzz.txt
if %RET_VAL% gtr 0 (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== ERROR CREATING VERSION ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo part1 error is %part1%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
echo.
echo Error Creating Version.
)
goto EXIT_SUB_setup_new_project
)
REM Get Version ID
for /F tokens^=3^ delims^=:^" %%Z in ("%part1%") do (
set VERS_ID=%%Z
)
echo Version ID: is %VERS_ID%
if %DEBUG% NEQ 0 (
echo Version ID: is %VERS_ID%
)
if %DEBUG% NEQ 0 pause
REM ================================================================================================
:create_datapool
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF CREATE DATAPOOL ==========
if %DEBUG% NEQ 0 echo.
del /Q /F zzz.txt
REM Create Datapool (Data generator)
for /F "tokens=1 delims=," %%A in ('curl -X POST --insecure --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer %SEC_TOKEN%" -d "{ \"description\": \"Clone of script ref data\", \"name\": \"%DB%\", \"projectId\": %PROJ_ID%, \"versionId\": %VERS_ID%}" "https://localhost:8443/TDMGeneratorService/api/ca/v1/generators?projectId=%PROJ_ID%&versionId=%VERS_ID%"') do (
set part1=%%A
)
REM Check for errors
echo %part1% | find /c "status" > zzz.txt
set /p RET_VAL= <zzz.txt
if %RET_VAL% gtr 0 (
set SKIP_CURR_DB=1
if %DSP_ERR% NEQ 0 (
echo ========== ERROR CREATING DATAPOOL ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo part1 error is %part1%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
echo.
echo Error Creating Datapool.
)
goto EXIT_SUB_setup_new_project
)
if %DEBUG% NEQ 0 pause
:EXIT_SUB_setup_new_project
REM Exit: SUB_Setup_New_Project
exit /b
goto skip_subroutines
REM ================================================================================================
REM Register Table
REM ================================================================================================
:SUB_register_table
if %SKIP_CURR_DB% NEQ 0 goto EXIT_SUB_setup_new_project
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF REGISTER TABLE ==========
if %DEBUG% NEQ 0 echo.
SET TBLNAME=table.json
REM Path to %TBLNAME% file is always fixed
del /Q /F D:\temp\%TBLNAME%
REM ERROR CHECKING
echo ^{^"objectType^"^:^"TABLE^"^,^"schema^"^:^"dbo^"^,^"connectionProfileName^"^:^"%CON_PROF%^"^,^"tableNames^"^:^[^"%TABLE%^"^]^} >D:\temp\%TBLNAME%
if %DEBUG% NEQ 0 (
echo.
type D:\temp\%TBLNAME%
echo.
echo Start of table register for %TABLE%
echo.
)
curl -X POST --insecure -H "Authorization: Bearer %SEC_TOKEN%" -H "Cache-Control: no-cache" -F "body=@d:/temp/%TBLNAME%;type=application/json" "https://localhost:8443/TDMModelService/api/ca/v1/objects?projectId=%PROJ_ID%&versionId=%VERS_ID%"
if %DEBUG% NEQ 0 (
echo.
echo.
pause
)
exit /b
goto skip_subroutines
REM ================================================================================================
REM Add header information
REM ================================================================================================
:SUB_header_add
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF HEADER ADD ==========
if %DEBUG% NEQ 0 echo.
set FOLDER=%~3
if %DEBUG% NEQ 0 echo DATA FOLDER IS SET NOW TO BE %FOLDER%
REM Clean up any CSV files
del /Q /F "%FOLDER%*.csv"
if %DEBUG% NEQ 0 pause
SET TBLNAME=table.json
set FLSIZE=0
set RET_VAL=-1
REM set FIRST_LINE=""
if %DEBUG% NEQ 0 echo ========== START OF HEADER ADD for loop ==========
for %%f in ("%FOLDER%*.txt") do (
if %DEBUG% NEQ 0 (
echo PROCESSING TABLE - %%~nf
pause
)
REM ===== SQLCMD Section =====
sqlcmd -S %SERVER% -U %SQLUSER% -P %SQLPW% -d %DB% -s, -W -Q "select top 0 * from %%~nf" >"%FOLDER%%%~nf.csv"
REM if sucsessful, it should contain text: (0 rows affected)
type "%FOLDER%%%~nf.csv" | find /c "(0 rows affected)" > zzz.txt
set /p !RET_VAL!= <zzz.txt
if !%RET_VAL%! gtr 0 (
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo Header found in Source Database
if %DEBUG% NEQ 0 echo.
REM REM Now extract first line containing the Field/Column names.
call :SUB_Get_First_Line "%FOLDER%%%~nf.csv"
REM echo Back from SUB-Routine
REM echo !NLINE!
REM pause
) else (
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo SQLCMD failed to find field information for table: %%~nf
REM Create empty CSV file to be captured downstream as an error.
type NUL > "%FOLDER%%%~nf.csv"
if %DEBUG% NEQ 0 pause
)
REM TMP EXIT
REM goto end_fin
REM ===== *** END SQLCMD Section END *** =====
REM sqlcmd -S %SERVER% -U %SQLUSER% -P %SQLPW% -d %DB%1 -s, -W -Q "select top 0 * from %%~nf" | find /v "-" |find "," >"%FOLDER%%%~nf.csv"
REM echo ERRLVL=%errorlevel%
REM exit /b
rem for /f %%k in ("%FOLDER%%%~nf.csv") do set FLSIZE=%%~zk
rem 2 for %%k in ("C:\Temp\API-Curl\TESTDATA\Aggregated_Asset_Status.txt") do SET FLSIZE=%%~zk
for %%k in ("%FOLDER%%%~nf.csv") do (
set !FLSIZE!=%%~zk
)
REM echo File Size = !%FLSIZE%!
if !%FLSIZE%! gtr 0 (
if %DEBUG% NEQ 0 echo Header created successfully.
type "%FOLDER%%%~nf.txt" >> "%FOLDER%%%~nf.csv"
REM ERROR CHECKING
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 echo ========== START OF HEADER ADD Register==========
del /Q /F D:\temp\%TBLNAME%
REM ERROPR CHECKING
REM Path to %TBLNAME% file is always fixed
echo ^{^"objectType^"^:^"TABLE^"^,^"schema^"^:^"dbo^"^,^"connectionProfileName^"^:^"%CON_PROF%^"^,^"tableNames^"^:^[^"%%~nf^"^]^} >D:\temp\%TBLNAME%
if %DEBUG% NEQ 0 type D:\temp\%TBLNAME%
if %DEBUG% NEQ 0 echo Start of table register for %%~nf
curl -X POST --insecure -H "Authorization: Bearer %SEC_TOKEN%" -H "Cache-Control: no-cache" -F "body=@d:/temp/%TBLNAME%;type=application/json" "https://localhost:8443/TDMModelService/api/ca/v1/objects?projectId=%PROJ_ID%&versionId=%VERS_ID%"
) else (
echo.
echo File %FOLDER%%%~nf.csv is Empty SQL command not worked
echo ERROR creating HEADER
echo deleting empty file
del /Q /F "%FOLDER%%%~nf.csv"
echo.
)
)
if %DEBUG% NEQ 0 echo.
if %DEBUG% NEQ 0 pause
REM Exit: SUB_header_add
exit /b
goto skip_subroutines
REM ================================================================================================
REM Create a file containing the first line from specified file
REM
REM PARAMETERS:
REM - Input path+file. This is overwritten later with the first line from input file.
:SUB_Get_First_Line
set NFIRST=1
set NLINE=-1
for /f "delims=" %%a in ('type %1') do (
if !NFIRST!==1 set NLINE=%%a
set NFIRST=0
)
echo %NLINE% > %1
exit /b
goto skip_subroutines
REM ==================
:skip_subroutines
REM ==================
REM ================================================================================================
REM Error Jump Section
REM ================================================================================================
:error_jump_section
REM sucsessful finish
if %DEBUG% NEQ 0 echo ========== FINISH ==========
echo Server entered is %SERVER%
echo Database entered is %DB%
echo full folder path is %FOLDER%
echo Project ID: is %PROJ_ID%
echo Version ID: is %VERS_ID%
echo security token is %SEC_TOKEN%
goto end_good
REM ================================================================================================
:end_good
echo.
echo Processing completed.
echo.
goto end_fin
REM ================================================================================================
:end_fin