eclipse-basyx / basyx-java-server-sdk

MIT License
49 stars 42 forks source link

BaSyx AAS Environment Component - Cant´t post new SubmodelElement in existing SubmodelElementColletion #283

Closed BjoernKaemper closed 2 weeks ago

BjoernKaemper commented 1 month ago

Hello,

I am currently working with the BaSyx AAS Environment Component and have been stuck on an HTTP post command for a few hours.

I have an existing AAS with an added submodel in the Env component. I have realized everything with the API described in the Swagger documentation. I can also display the content in the AAS UI.

Problem: I cannot insert a new SEM into an existing SEMC using the http post command.

With the following command, the property "exampleProperty2" is added at the first level in the submodel and not in the existing SubmodelElementCollection "exampleSEMC". POST- http://localhost:8081/submodels/U3VibW9kZWxJRDE/submodel-elements/exampleSEMC body: { "idShort": "exampleProperty2", "modelType": "Property", "value": "helloWorld2" }

When using the following command I get a 409 error message: POST-http://localhost:8081/submodels/U3VibW9kZWxJRDE/submodel-elements/exampleSEMC.exampleProperty2 { "idShort": "exampleProperty2", "modelType": "Property", "value": "helloWorld2" }

I have no problems with the following commands and can use them to trace my problem: POST-http://localhost:8081/submodels/U3VibW9kZWxJRDE/submodel-elements/exampleProperty body: { "idShort": "exampleProperty", "modelType": "Property", "value": "helloWorld" }

POST-http://localhost:8081/submodels/U3VibW9kZWxJRDE/submodel-elements/exampleSEMC body: { "idShort": "exampleSEMC", "modelType": "SubmodelElementCollection", "value":[ { "idShort": "exampleProperty", "modelType": "Property", "value": "helloWorld" } ] }

GET- http://localhost:8081/submodels/U3VibW9kZWxJRDE/submodel-elements/exampleSEMC GET- http://localhost:8081/submodels/U3VibW9kZWxJRDE/submodel-elements/exampleSEMC.exampleProperty

Am I using the dot notation incorrectly or do I have to work with a PUT command here? I pulled the newest Docker image today.

Greetings from Cologne, Björn :)

mateusmolina-iese commented 1 month ago

Hi Björn,

your first request should have worked to a add a new SE to an existing SEC.

Could you please attach a minimal example containing your config files (properties, docker-compose, AASX files), so we can reproduce the issue?

Thanks in advance, Mateus

BjoernKaemper commented 1 month ago

I use the example component and have only released the ports for mongo in the dockercompose.yml. I think I also deleted all docker images beforehand to make sure that an old one is not used during the installation.

Starting the docker-compose works fine with "docker-compose up -d" and all components are running healthy.

All my http commands i send via postman

BaSyxExample.zip

BjoernKaemper commented 1 month ago

I assemble my AAS, the submodel and the SEMC etc. as follows: http-POST: http://localhost:8081/shells (works) body:

{
    "idShort": "testAas",
    "id":"testAasId"
}

http-POST: http://localhost:8081/submodels (works) body:

{
    "idShort": "testSubmodel",
    "id":"testSubmodelId"
}

http-POST: http://localhost:8081/shells/dGVzdEFhc0lk/submodel-refs (works) Body:

{
        "keys": [
            {
                "type": "Submodel",
                "value": "testSubmodelId"
            }
        ],
        "type": "ModelReference"
}

http-Post: http://localhost:8081/submodels/dGVzdFN1Ym1vZGVsSWQ=/submodel-elements (works)

{
    "idShort": "ExampleSEMC",
    "modelType": "SubmodelElementCollection"
}

http-Post: http://localhost:8081/submodels/dGVzdFN1Ym1vZGVsSWQ=/submodel-elements/ExampleSEMC (http status 201 but its again at the wrong level and not inside “ExampleSEMC”)

{
    "idShort": "ExampleProp",
    "modelType": "Property"
}
de-ich commented 1 month ago

I have the same problem using the latest BaSyx AAS Environment Docker image:

Executing an HTTP post to {{Endpoint}}/submodels/{{SubmodelId}}/submodel-elements/Segments.InternalSegment.Records will always add the element passed in the request body as a top-level element as direct child of the submodel instead of as a child of ...Records. HTTP get to the above adress works fine so the idShort-Path should be correct.

The same problem exists even when posting to {{Endpoint}}/submodels/{{SubmodelId}}/submodel-elements/Segments, i.e. when an idShort-Path with only one element is used.

FriedJannik commented 4 weeks ago

Hi Björn, the issue you faced was indeed a bug. We fixed it with the PR mentioned above. Until the docker images are getting updated you can build the Images with the latest bug fix yourself when the PR is merged.

de-ich commented 1 week ago

@FriedJannik I used the current version of the 2.0.0-SNAPSHOT build of the eclipsebasyx/aas-environment component. However, I am still experiencing the same problems as described above. As the image was updated yesterday, I guess that it should already contain this fix?

FriedJannik commented 1 week ago

Hi @de-ich, to use the new docker image, you have to remove the old image first, as the Version Tag is not changed, so docker does not automatically pull the new version. I just checked it, and for me it works just fine. Let me know if you need any further help :)

de-ich commented 1 week ago

@FriedJannik I did delete the old image first so I am using the new image aswell. However, now that I know that it should work, I will investigate further and try to provide a minimum working example.