Expand my Community achievements bar.

Getting 200 OK when trying to install package through Restful API

Avatar

Level 2

So I'm trying to build a plugin for my IDE to automatically sync up changes to my local AEM by pushing a small package up with my changes.  I found the REST API's here: List of common AEM cURL commands

I am calling the API as instructed and I get back a 200 OK from the API.  However, when I look in my package manager, I don't see the package at all.  Is there a header or something I need that may be missing? There is nothing in the logs as far as I can tell either.

This is the URL I am calling from my script:  http://admin:admin@localhost:4502/crx/packmgr/service.jsp

This is the response:

<crx version="1.2.2" user="admin" workspace="crx.default">

sync.js:21

  <request>

  </request>

  <response>

    <data>

      +------------+-----------------------------------------+

      |  Arguments | Comment                                 |

      +------------+-----------------------------------------+

      |  cmd=help  | print this help                         |

      +------------+-----------------------------------------+

      |  cmd=ls    | print a list of all packages            |

      +------------+-----------------------------------------+

      |  cmd=rm    | remove a  package                       |

      |  name      | package name                            |

      |  [group]   | group name (optional)                   |

      +------------+-----------------------------------------+

      |  cmd=build | build a  package                        |

      |  name      | package name                            |

      |  [group]   | group name (optional)                   |

      +------------+-----------------------------------------+

      |  cmd=inst  | install a package                       |

      |  name      | package name                            |

      |  [strict]  | true to fail on error                   |

      |  [group]   | group name (optional)                   |

      +------------+-----------------------------------------+

      |  cmd=uninst| uninstall a package                     |

      |  name      | package name                            |

      |  [group]   | group name (optional)                   |

      +------------+-----------------------------------------+

      |  GET       | download a package                      |

      |            | (content-disposition header contains    |

      |            | the correct filename)                   |

      |  [cmd=get] | optional                                |

      |  name      | package name                            |

      |  [group]   | group name (optional)                   |

      +------------+-----------------------------------------+

      |  POST      | upload a new package                    |

      |  file      | package to upload                       |

      |  [name]    | optional name                           |

      |  [strict]  | true to fail on install error           |

      |  [install] | automatically install package if 'true' |

      +------------+-----------------------------------------+

    </data>

    <status code="200">ok</status>

  </response>

</crx>

As well, here is the form I am submitting:

                file: fs.createReadStream(packagePath),

                force: "true",

                install: "true"

Is there a header or something I need?  Is there any way to debug this?  The response doesn't tell me anything and as far as I can tell, I am submitting the request according to the URL I posted above.

AS WELL, I've tested uploading the package manually via the Package Manager web interface and it installs fine.  So the package is good.

5 Replies

Avatar

Level 10

If you want to programmatically install a pakage - its better to use the Package Manager API - Install a package in package manger programatically

Avatar

Level 2

Correct me if I am wrong, that's a Java API?  The extension I am building has to be in NodeJS, so I believe I am limited to the HTTP API, or perhaps Filevault API.

Avatar

Level 10

In that case - look at building a custom SLing Servlet. Use the Package Manager API on the Servlet side and then you can still invoke the Servlet using HTTP.

Avatar

Level 2

I was kind of hoping to have a more general extension that we can use on any project without anything custom on the AEM side.   Those REST API's on your site looked like the perfect solution, and I've seen some other people using them online, but I just cannot replicate the success they've had with them.

Avatar

Level 10

Maybe others have had success of using CURL to upload packages. I typically prefer the use of the Strongly-Typed API as in my experience - find it works better.