Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Problems with the Storage API

Problems with the Storage API

cdutz
Long-established Member

Hi all,

so I'm making good progress ... however with the Storage API I'm having a bit of trouble.

If I call the following url in the Swagger UI:

https://192.168.42.100/storage/api/v1/media

I get this response:

[  {
    "uuid": "C2E7-F514",
"label": "Extreme SSD",
"mounted": false,
"format": "exfat",
"size": 1000169226752,
"device": "sda1" }, { "uuid": "d2d26aa9-0ab9-4ecf-aff8-f8194080ee02",
"label": "ubuntu-data",
"mounted": true,
"format": "ext4",
"size": 2917068800,
"used": 1074192384,
"device": "mmcblk0p4",
"internal": true }, { "uuid": "4A65-4441",
"mounted": false,
"format": "fat32",
"size": 15633219584,
"device": "mmcblk1p1" } ]

I guess my "extreme" SSD should probably be an "extern" SSD (because that's what it is). 

As you can see, I added an external USB SSD device as well as an micoSD card in the card reader slot.
The problem is, that I can't decode the response from the generated client as the "exfat" format is not specified in the spec. I'll probably manually add this in order to be able to continue, but I thought I'd report this, so it can be added to the list of constants.

7 REPLIES 7

cdutz
Long-established Member

Also does it list my external SSD and the microSD card as "unmounted". Now I would have expected that I could use the tasks api to mount them, however it looks as if the only option I have there seems to be to unmount them. Could someone tell me what the right process would be to use this API to mount them too?

Sgilk
Frequent Contributor

Hi,

Could you please clarify what you mean in your initial post by "the exfat format is not specified in the spec"? I see all of your devices returned a "format" key.

You should be able to mount devices using the storage api tasks endpoint. For whatever reason, this isn't included in the examples though.

POST to...

https://127.0.0.1:8443/storage/api/v1/tasks

Schema:

Sgilk_0-1698929332239.png

The call would then look like this...

 

{
   "action": "mount",
   "parameters": {
      "media": "UUID",
      "assignment": "data-exchange/storage-extension"
   }
}

 

CodeWasi
Occasional Contributor

The example boxes of the Post-trials will be updated soon by the mount assignment. Please operate in the meantime with the schema infos or F12 Reverse-Engineering.

cdutz
Long-established Member

Hi, 

in the OpenAPI json document the format of "exfat" is not included:

cdutz_0-1698931119511.png

So my generated client didn't know how to parse that. I solved the problem by manually adding the constant to the generated class, but that's not an ideal solution. I guess if you just pass along unvalidated payloads in simple json or yaml structures, this doesn't matter, but as soon as something's strongly typed, that doesn't work. Also a bit odd that the server actually sends out responses that are not valid according to it's own specs.

And regarding the mounting, when looking at the Swagger UI, the only option I see in the UI, is "unmount". I usually try out the things I try in that and as I couldn't generate a "mount" command, I thought it wasn't supported. But looking into the details of TaskMount I'll simply book that under shortcoming of the Swagger UI.

Thanks,

     Chris

 

cdutz
Long-established Member

So I've been trying to manually post requests to mount the devices, but the PLC keeps on responding with "400 bad request".
One version I tried, based on the documentation on the Swagger UI I tried this:

 

POST https://192.168.42.100/storage/api/v1/tasks
Content-Type: application/json
Accept: application/json
Authorization -> Bearer eyJhbGciOiJFUzM4N--- snip ---fvxWHsbqx5W3pZJ: 
Content-Length: 106
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8.1)
Accept-Encoding: br,deflate,gzip,x-gzip

{
  "action":"mount",
  "parameters":{
    "media":"C2E7-F514",
    "assignment":"storage-extension"
  }
}

 

The "media" was the "UUID" of my removable device as returned by:

https://192.168.42.100/storage/api/v1/media

 

[
  {
    "uuid": "C2E7-F514",
    "label": "Extreme SSD",
    "mounted": false,
    "format": "exfat",
    "size": 1000169226752,
    "device": "sda1"
  },
  {
    "uuid": "4A65-4441",
    "mounted": false,
    "format": "fat32",
    "size": 15633219584,
    "device": "mmcblk1p1"
  },
  {
    "uuid": "d2d26aa9-0ab9-4ecf-aff8-f8194080ee02",
    "label": "ubuntu-data",
    "mounted": true,
    "format": "ext4",
    "size": 2917068800,
    "used": 1074720768,
    "device": "mmcblk0p4",
    "internal": true
  }
]

 

The output the generated OpenAPI client would have produced was quite a bit different and the server didn't like it either:

 

{
  "instance":{
    "parameters":{
      "media":"C2E7-F514",
      "assignment":"storage-extension"
    },
    "action":"mount"
  },
  "isNullable":false,
  "schemaType":"oneOf"
}

 


Help greatly appreciated.

 

Sgilk
Frequent Contributor

The command below is working on my micro-SD in Ext4 format.

 

curl -X 'POST' \
  'https://192.168.1.100/storage/api/v1/tasks' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTg5NjYxODQsImlhdCI6MTY5ODkzNzM4NCwiaWQiOiIxMDAwIiwibmFtZSI6ImJvc2NocmV4cm90aCIsIm5vbmNlIjoiNzU4NjU1MjQtM2Q3MC00YzNmLWExNDAtZTA1NzI5ZjBmOWFmIiwicGxjaGFuZGxlIjowLCJyZW1vdGVhdXRoIjoiIiwic2NvcGUiOlsicmV4cm90aC1kZXZpY2UuYWxsLnJ3eCJdfQ.ydKR7RzYQGrR8VOG4ZpY3aUAwT2yH1yOua8XpZdkypuVH5BtTW4cm0me6m9duZo1F3GH73siOOQD8kQaAkQOlRY4uCLF9I_Zq-t3sGA119r_wTjMslI8XpHe2Wic1Mns' \
  -H 'Content-Type: application/json' \
  -d '{
  "action": "mount",
  "parameters": {
    "media": "91f34d0c-9859-42be-b945-d0eeaa805d8d",
    "assignment": "data-exchange"
  }
}'

 

Response:

 

{
  "id": "2",
  "state": "pending",
  "eta": "2023-11-02T10:06:37.43626618-05:00",
  "action": "mount",
  "parameters": {
    "assignment": "data-exchange",
    "media": "91f34d0c-9859-42be-b945-d0eeaa805d8d"
  },
  "result": {
    "type": "",
    "title": ""
  }
}

 

The 400 error makes it seem like your REST API request format is incorrect, although admittedly the error message isn't very helpful. I also think you will need to format your disc to Ext4 or Fat32.

See: Formatting External Storage 

cdutz
Long-established Member

Ok ... so thanks @Sgilk ... after copying line for line (of course using my UUID instead) I managed to find the problem ... in the bearer token line, the header was wrong. Not sure where the "->" came from, so that was what it was complaining about ... after changing that I got a successful task creation, however the task failed as it seems that "storage-extension" only works on encrypted storage, so I tried with "data-exchange" and that worked.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist