Author Topic: REST API  (Read 4066 times)

rzaidullin

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
    • rzaydullin.com
REST API
« on: October 06, 2021, 11:24:46 pm »
Hi

I have objective to create a requirement, so trying to run POST requests as described in instructions

Server looks configured and running - I am able to connect with client app to a project hosted on cloud and create a requirement

When I am running POST request to create a new requirement the response is "The request contains invalid XML"
When I am trying to GET data - the response is "Authentification required" or kind of that
When I am trying to run POST request to authenticate I get "unsupported method" (tried to get authentication token with security disabled on Model and with enabled security)

Need some help

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7615
  • Karma: +96/-18
    • View Profile
Re: REST API
« Reply #1 on: October 07, 2021, 08:21:11 am »
When I am running POST request to create a new requirement the response is "The request contains invalid XML"
It would probably help if you shared the endpoint and post contents.

Without having had too much to do with the OSLC interface 3 things come to mind.
  • There is a fault in your XML
  • The XML that you sent isn't what the request expected
  • The XML that you sent doesn't declare a codepage or the server is requesting something particular

When I am trying to GET data - the response is "Authentification required" or kind of that
https://sparxsystems.com/enterprise_architect_user_guide/15.2/pro_cloud_server/oslc_user_cred.html

When I am trying to run POST request to authenticate I get "unsupported method" (tried to get authentication token with security disabled on Model and with enabled security)
It would probably help if you shared the endpoint and post contents. I could assume you're following the instructions in the above link, but that won't help anyone.
Eve

support@sparxsystems.com

rzaidullin

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
    • rzaydullin.com
Re: REST API
« Reply #2 on: October 07, 2021, 09:56:30 pm »
Thank you Eve,

here is endpoint for login: http://localhost:804/fb-procloud/oslc/am/login
Model has no security enabled, so I am sending uid=;pwd=;
the respond has 405 code, "The request cannot be fulfilled as the request method is not supported"

endpoind for creation is: http://localhost:804/fb-procloud/oslc/cf/
the XML for creation body is (I tried different values for package id - numbers and name) just as described:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:oslc_rm="http://open-services.net/ns/rm#"
         xmlns:dcterms="http://purl.org/dc/terms/"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:ss="https://sparxsystems.com.au/">
    <oslc_rm:requirement>
        <dcterms:title>Requirement3</dcterms:title>
        <dcterms:description>Requirement Notes</dcterms:description>
        <dcterms:creator>
            <foaf:Person>
                <foaf:name>Sparx</foaf:name>
            </foaf:Person>
        </dcterms:creator>
        <ss:type>Functional</ss:type>
        <ss:packageID>newPackage</ss:packageID>
    </oslc_rm:requirement>
</rdf:RDF>

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7615
  • Karma: +96/-18
    • View Profile
Re: REST API
« Reply #3 on: October 08, 2021, 09:25:02 am »
here is endpoint for login: http://localhost:804/fb-procloud/oslc/am/login
No trailing slash on your endpoint.

URL: <protocol>://<server>/<model_name>/oslc/am/login/

the XML for creation body is (I tried different values for package id - numbers and name) just as described:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:oslc_rm="http://open-services.net/ns/rm#"
         xmlns:dcterms="http://purl.org/dc/terms/"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:ss="https://sparxsystems.com.au/">
    <oslc_rm:requirement>
        <dcterms:title>Requirement3</dcterms:title>
        <dcterms:description>Requirement Notes</dcterms:description>
        <dcterms:creator>
            <foaf:Person>
                <foaf:name>Sparx</foaf:name>
            </foaf:Person>
        </dcterms:creator>
        <ss:type>Functional</ss:type>
        <ss:packageID>newPackage</ss:packageID>
    </oslc_rm:requirement>
</rdf:RDF>
What I don't see described, what code page are you sending that in? If it's not UTF8 that would explain why the server can't read your XML.

PS. If you get past that, you will need a numeric package id corresponding to a package that exists in your model in that field.
Eve

support@sparxsystems.com

rzaidullin

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
    • rzaydullin.com
Re: REST API
« Reply #4 on: October 14, 2021, 11:16:12 pm »
here is endpoint for login: http://localhost:804/fb-procloud/oslc/am/login
No trailing slash on your endpoint.

URL: <protocol>://<server>/<model_name>/oslc/am/login/

the XML for creation body is (I tried different values for package id - numbers and name) just as described:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:oslc_rm="http://open-services.net/ns/rm#"
         xmlns:dcterms="http://purl.org/dc/terms/"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:ss="https://sparxsystems.com.au/">
    <oslc_rm:requirement>
        <dcterms:title>Requirement3</dcterms:title>
        <dcterms:description>Requirement Notes</dcterms:description>
        <dcterms:creator>
            <foaf:Person>
                <foaf:name>Sparx</foaf:name>
            </foaf:Person>
        </dcterms:creator>
        <ss:type>Functional</ss:type>
        <ss:packageID>newPackage</ss:packageID>
    </oslc_rm:requirement>
</rdf:RDF>
What I don't see described, what code page are you sending that in? If it's not UTF8 that would explain why the server can't read your XML.

PS. If you get past that, you will need a numeric package id corresponding to a package that exists in your model in that field.

Thank you, Eve. Looks like the missing slash in the endpoint for login was blocking all my efforts. We even have drawn tables in notes field, great success (but it works only in webEA)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7615
  • Karma: +96/-18
    • View Profile
Re: REST API
« Reply #5 on: October 15, 2021, 08:41:21 am »
Thank you, Eve. Looks like the missing slash in the endpoint for login was blocking all my efforts. We even have drawn tables in notes field, great success (but it works only in webEA)
Shh. Keep it to yourself if you like it. Sounds like something should be validating content a little better.
Eve

support@sparxsystems.com