Unable to import project via API - Request to check this out
See original GitHub issueHi team 👋
I’ve been trying to import a project to my CastleMock instance (version 1.55). Based on the Swagger specification, I built this curl:
curl --location --request POST 'http://localhost:8080/castlemock/api/rest/core/project/rest/import?type=rest' \ --header 'Authorization: Basic eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJjYXN0bGVtb2NrIiwiZXhwIjoxNjIyNDg2MjM3LCJ1c2VySWQiOiJtQ3NGWUEifQ.SvFL4dYXkUzNQpNNAPijheCj81ueffIw6EmRHSe9_eA8Zm8bTJMuEoxZGknhpy4_56B80H8qmxoCA9kO7Y5Ia0IKc2KUUM3h9RnjuOgiIWacxTMqcCetLlfPFP5XLrbFC2MsZbps1MGoC4qucjxigE9emcgoFhq6TVAizT15HjJ5j4Bsy-MyV8xYHWsrO6D04ikOm7HoWDAavYr_d0A1V_Uze6QWWaLKYlkS-CxQfc84E7oR6SJZk7hv7pxEngJKW31pgwl7FNh2i9f9JOhHA2hGXo2U-EF9QdQ8sgzv9T2MTEOfgPPAmCefmFTRxPRcs2RCT5_Khbjzx4KUdqn_Ow' \ --form '=@"/home/nico/Desktop/Project-2021-03-08.xml"'
and always got unauthorized
{"timestamp":"2021-05-24T19:21:21.330+00:00","status":401,"error":"Unauthorized","message":"","path":"/castlemock/api/rest/core/project/rest/import"}
I generated the token from Swagger (http://localhost:8080/castlemock/swagger-ui) and then used it in Postman.
Wonder if I missing something or there is actually an issue. Any help/observation is welcome.
Thank you in advance! 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
Hi @nicohv. My apologies for the late response here. Regarding query param filtering: Yes, Castle Mock supports matching mocked responses based on incoming query parameters. More information can be found here: https://github.com/castlemock/castlemock/wiki/Use-Case:-REST#query-match
I hope you found this answer helpful.
Best regards, Karl
Hi @nicohv. My guess is that the Authorization header is invalid. The correct value is Authorization: Basic {Base 64 encoded username:password}.
Example: Authorization: Basic admin:admin Example (Encoded) Authorization: Basic YWRtaW46YWRtaW4=
You can easily encode your username and password on this page: https://www.base64encode.org/
I was certain that I had created an article about this on our Wiki, but it seems that I have missed that. I will definitely do that as soon as I have some time over. For now, you can find more information regarding basic authentication on this Wikipedia article: https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side
I hope this helps. If not, please don’t hesitate to write again. Good luck! Best regards, Karl Dahlgren