Hi All,

Current import/export tool doesn't facilitate updating a imported API. I
modified the implementation of import/export tool in APIM to update a API
once its been try to import a already imported API using APIM REST API.

When a user attempt to import a existing  API using *"*create a new API*" *REST
API [ 1.
https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APICollectionApi#apisPost]
, server gives out a error with code 409 stating a conflict. On it, then
check whether the user has set the value of query parameter
"updateIfExists" to true.(Refer the following example)

eg :-
curl -H "Authorization:Basic AbCdEfG" -F file=@
"/Desktop/MyAPIFolder/myExportedAPI.zip" -k -X POST "
https://10.100.7.40:9443/api-import-export-<version>/import-api?
*updateIfExists=true*"

 If then, update the existing API using following REST APIs,

   - Update the existing API -
   
https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APICollectionApi#apisApiIdPut
   - Delete the existing API documents -
   
https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APIDocumentApi#apisApiIdDocumentsDocumentIdDelete
   - Add exported API documents -
   
https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APIDocumentApi#apisApiIdDocumentsPost

   - Update document contents -
   
https://docs.wso2.com/display/AM1100/apidocs/publisher/#!/operations#APIDocumentApi#apisApiIdDocumentsDocumentIdContentPost
   - Add API thumbnail by calling to the end point
   http://localhost:9763/api/am/publisher/v0.9//apis/{apiId}/thumbnail
   
<http://www.google.com/url?q=http%3A%2F%2F127.0.0.1%3A9763%2Fapi%2Fam%2Fpublisher%2Fv0.9%2F%2Fapis%2Ff7ac5958-e581-4631-9c39-bb7d0795cf7c%2Fthumbnail&sa=D&sntz=1&usg=AFQjCNEpM0xz1acxH3fPPubOP-RG_WhTsA>
   with corresponding image file.

else, If the value of query parameter "updateIfExists" is false, importing
action ends up giving a appropriate error message stating API trying to
create already exists.
If there are any feedback on this procedure please reply.

Regards,

-- 
Kaveesha Perera
Intern - Software Engineering

mobile: 0716130471
_______________________________________________
Architecture mailing list
Architecture@wso2.org
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to