How-to Create a Rest API - first attempt

0
I’m trying to use the Youtube videos (How-to Create a Rest API - *) by Jeff Goldberg to create (and learn) a REST API for an application interface.  I’m getting an error, and have tried to debug, but I don’t know how to troubleshoot any deeper than from the MX microflow, well, let me explain.  The GET method works just like the video directs.  On the PUT method, I’m apparently not getting back to the API (I say this because I’ve put a breakpoint in the microflow for the PUT, but it never triggers.  On the GET this works just fine.).  For the PUT, in SwaggerUI I’m getting the response 500, like it’s never hitting the microflow. Any guidance anyone can offer?  Thank you in advance!!! The AddVehicles microflow The Swagger call is: curl -X POST "http://localhost:8080/v1/collection/vehicle" -H "accept: application/json" -H "Content-Type: application/json" -d "[{\"VehicleId\": 0,\"Make\": \"Jaguar\",\"Model\": \"XKE\",\"Color\": \"British Racing Green\",\"Year\": 1967,\"Style\": \"Coupe\"},{\"VehicleId\": 0,\"Make\": \"Ford\",\"Model\": \"F150\",\"Color\": \"White\",\"Year\": 1994,\"Style\": \"Truck\"}]"
asked
2 answers
0

Have you tried putting the log level of “REST Publish” up to TRACE. That should reveal what is happening for every request to your REST service in the console. Hopefully it will give you some clues.

Good luck!

answered
0

Nice!  Thanks Robert.  I will use this more often now! 

Turns out it wasn’t a coding error, it was a data error… apparently I had the sample input data incorrectly formatted.  Only thing that I really see is the first element of the array starting on the “array opening specification”.

This is an apparent Error:
[{
        "VehicleId": 0,
        "Make": "Jaguar",
        "Model": "XKE",
        "Color": "British Racing Green",
        "Year": 1967,
        "Style": "Coupe"
    }, {
        "VehicleId": 0,
        "Make": "Ford",
        "Model": "F150",
        "Color": "White",
        "Year": 1994,
        "Style": "Truck"
    }
]

But, this Works:
[
  {
    "VehicleID": 0,
    "Make": "Jaguar",
    "Model": "XKE",
    "Color": "British Racing Green",
    "Year": 1967,
    "Style": "Coupe"
  },  {
    "VehicleID": 0,
    "Make": "Ford",
    "Model": "F150",
    "Color": "White",
    "Year": 1994,
    "Style": "Truck"
  }

]

answered