I am trying to update a existing stream target and it seems I cant update just the streamName and leave all other bits as they are using PUT as from what I can see, I need to specify all the other parameters even though I don’t really want to change those… In such case, I really can’t see the difference between POST and PUT. I can understand that in POST all the parameters are required to create the stream target but why would they be needed to update an existing stream targets single parameter like the streamName and leave all the other bits as they are?
Have I missed any logic behind it or am I doing somthing wrong?
I do kind of agree to you. (At first glance). To illustrate this better i would like to point out two primary differences between POST and PUT request first.
-
By API design standards a post request will result in creation of a source. Repeated runs is supposed to either create more resources or just throw an errror based on key existence,. Whereas repeated PUT request does not do anything. That is to say PUT
method is idempotent So if we retry a request multiple times, that should be equivalent to a single request invocation.
-
A PUT request will usually have a unique URI pertaining to that resource along with supplied parameters. Ex: PUT /questions/{question-id}
. A POST on the other hand will not have one because the resource is not expected to exist. It is the parameters/post entity that matter more.
Now coming to the streamTarget API, the URI for both PUT and POST is the same. If you look at the example the uri is:
http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/pushpublish/mapentries/ppsource
I believe it is so because the JSON object that is provided as entity facilitates in creating the internal map (like a hashmap or something). The JSON items serve as key-value pairs for he map directly. I believe this type of resource cannot have a separate resource ID associated with it as the entryName
seems to be the main resource. So when you POST the internal properties map is created and when you PUT the map is updated. While i do agree that all properties should not ideally be mandatory and that properties can be selectively updated in a map, i guess that is a design decision taken by wowza developers.
This is my 2 cents on this, unless wowza staff have a different explanation.
1 Like
thank you for this. It’s a shame that I can’t update individual properties using PUT. I guess I just have to read all the values for a particular streamTarget and then make the relevant change and push it all back to the server again; unless Wowza support has any other solution.