Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only

How to use DB2 on Cloud REST API to load data from IBM Cloud Object Storage CSV file?

  • 1.  How to use DB2 on Cloud REST API to load data from IBM Cloud Object Storage CSV file?

    Posted Mon January 20, 2020 04:50 AM

    I have been unable to use the Db2 on Cloud REST API to load data from a file in IBM Cloud Object Storage, as per the docs Db2 on Cloud REST API - IBM Cloud API Docs (Db2 on Cloud REST API - IBM Cloud API Docs).  This is preventing a hybrid integration POC.

    Another user has reported similar REST API issue using the SERVER configuration, see the IBM Developer thread at https://developer.ibm.com/answers/questions/526660/how-to-use-db2-on-cloud-rest-api-to-load-data-from.html

    I cannot seem to get the parameters correct, and I think the docs have errors in them for current Cloud Object Storage with HMAC keys ... such as for the endpoint to use, and whether auth_id should be the access_key_id

    I've tried a variety of data load commands, like the following, but none work. Can someone provide an example of a command that works (with any considerations/explanations for values)?

    curl -H "x-amz-date: 20200112T120000Z" -H "Content-Type: application/json" -H "Authorization: Bearer <auth_token>" -X POST "https://dashdb-txn-sbox-yp-lon02-01.services.eu-gb.bluemix.net:8443/dbapi/v3/load_jobs" -d '{"load_source": "SOFTLAYER", "schema": "MDW84075", "table": "SALES", "file_options": {"code_page": "1208", "column_delimiter": ",", "string_delimiter": "", "date_format": "YYYY-MM-DD", "time_format": "HH:MM:SS", "timestamp_format": "YYYY-MM-DD HH:MM:SS", "cde_analyze_frequency": 0 }, "cloud_source": {"endpoint": "https://s3-api.us-geo.objectstorage.softlayer.net/auth/v2.0", "path": "<bucket>/sales_data_test.csv", "auth_id": "<access_key_id>", "auth_secret": "<secret_access_key>"} }'

    Different attempts with the API call fail with a variety of messages, which usually do not have enough information to debug (and searches in doc/web do not find the messages); eg:

    {"trace":"","errors":[{"code":"not_found","message":"HWCBAS0030E: The requested resource is not found in service admin.","target":{"type":"","name":""},"more_info":""}]}


    P.S. I was able to use the DB2 on Cloud UI to load data from the file in COS S3, with the same access key values.



    ------------------------------
    Ian Larner
    ------------------------------

    #Db2