Closed gberl002 closed 2 years ago
It is because your data
property is a string and not an object. The API shouldn't choke on that but I'm curious to see the code used to generate that payload.
Here is the code used to generate the payload
interceptID := getConfigTypeByName(client,"intercept.v1").ID
interceptData := "'{\"protocols\":[\"tcp\"],\"addresses\":[\"simple.web.test\"], \"portRanges\":[{\"low\":80, \"high\":80}]}'"
dialConfName := "basic.dial"
dialConfig := &rest_model.ConfigCreate{
ConfigTypeID: interceptID,
Data: &interceptData,
Name: &dialConfName,
}
Looking at the generated code for Data
on the rest_model.ConfigCreate
struct, it is defining it as an interface{}
... which can basically be anything. However the actual back end requires that to be a map[string]interface{}
.
You should change your code to be the following:
interceptData := map[string]interface{}{
"protocols": []string{"tcp"},
"addresses": []string{"simple.web.test"},
"portRanges": []map[string]interface{}{
{
"low": 80,
"high": 80,
},
},
}
I'll put a fix in for the panic. Providing a string as you did results in a field that isn't checked before use.
That fixed it, thanks
I posted this payload to my edge controller. The same thing seems to work from postman but doesn't work from go test using the API.
This produced a 500 in the controller with the following stack: