Sonarqube Restore Qualityprofile using Java sonar-ws library


I’m trying to export and import qualityprofiles from one server to another using sonar-ws java library 8.9. Export goes OK, and I get the XML as a String, I can save it to a file or whatever.

But now, restore operation does not work, In the library RestoreRequest has a Backup parameter which is a string.

The exported XML doesn’t work if i send it as a string and I have seen Curl requests on Google where people use the restore endpoint using -F which uses a file as parameter. So any way to archive this using this library??
Would be a shame to use the library to everthing else and implement this request in other way.


Welcome to the community!

Have you tried this via the UI? Specifically, have you tried the ‘Restore’ function on the Quality Profiles page? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.


You’re right I can clearly see that backup parameter is a file.
Managed to get the curl request with Chrome Developer Tools and with Postman transform it to a java okhttp request. This kinda works but misses the point of the sonar-ws library since I’m using it for everything else.
How to send a binary file using only a string with the library is still a mistery