FIWARE-TMForum / Business-API-Ecosystem

The FIWARE/TMForum Business API Ecosystem allows the monetization of different kind of assets (both digital and physical) during the whole service life cycle, from offering creation to its charging, accounting and revenue settlement and sharing
https://business-api-ecosystem.rtfd.io/
GNU Affero General Public License v3.0
39 stars 22 forks source link

Create product using API #69

Closed johnnychoque closed 5 months ago

johnnychoque commented 5 months ago

Hello all,

I have installed the latest version of BAE local as well as the two plugins included in biz-basic-plugins. Using the marketplace GUI I have created a product. Apparently during the 'Product specifications' process of the GUI, the asset associated with the created product is also created:

Request

curl 'http://bae.docker:8004/charging/api/assetManagement/assets' --header 'Authorization: Bearer {{token}}'

Response

[
    {
        "id": "6662f38df15318fb8e42eb97",
        "version": "0.1",
        "contentType": "json-ld",
        "state": "attached",
        "href": "http://bae.docker:8004/charging/api/assetManagement/assets/6662f38df15318fb8e42eb97",
        "location": "http://www.smartsantander.net/pereda",
        "resourceType": "Basic Service",
        "metadata": {}
    }
]

Now I need to create another product that includes a similar asset to the previous one but this time using the API instead of the GUI. I understand that I must use the following API:

curl -X POST 'http://bae.docker:8004/DSProductCatalog/api/catalogManagement/v2/productSpecification' --header 'Authorization: Bearer {{token}}' --header 'Content-Type: application/json'

But to use the previous API I understand that it is necessary to previously create the new asset because I have to add a reference to that asset in the body of the request.

I can't find in the FIWARE BAE API documentation the request that allows to create the asset. I have tried to use the 'Upload asset task' request but it does not work.

Request

curl -X POST 'http://bae.docker:8004/charging/api/assetManagement/assets/uploadJob/' --header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{token}}' 
--data '{
  "version": "0.1",
  "contentType": "json-ld",
  "state": "attached",
  "location": "http://www.smartsantander.net/pereda",
  "resourceType": "Basic Service",
  "metadata": {}
}
'

Response

Status: 422 Unprocessable Entity
Body: Error: The digital asset has not been provided

Could you give me some insights to help me to create a product via API?

Best regards,

Johnny

johnnychoque commented 5 months ago

It was solved using POST /charging/api/assetManagement/assets/uploadJob/