go - GoLang- PostForm request for updating one of the resources of Cloudfoundry App -
I write the code to access the cloudfoundry platform and to summarize the data of all the applications pushed on the cloud.
I can access every app individually and display data related to each through a http.GET
request, but I will update some special data Want to change / app an app? This sample data xzys
has been an app called:
{ "metadata": { "guid": "71a3c77f-d2791232323-4b7625dq32908492b04f17e", "url ":" / V2 / apps / 71a3c77f-d2791232323-4b7625dq32908492b04f17e "," created_at ":" 2000-18-24 t "," updated_at ":" 2000-18-27T "}," unit ": {" name ": "xzys", "production": false, "space_guid": "65050bcb-81c6-45a2-b6ef-5e7097c7ece1", "stack_guid": "89a4fb19-08ef-4c44-90f7-f222a5699fdc", "buildpack": null, "detected_buildpack ":" Memory ": {}," memory ": 1024," example ": 3," disk_quata ": 512," state ":" start "," version ":" 67124c27-9958-45a7-afc5-5b27007348ab "," Command ": null," console ": false," debug ": null," staging_task_id ":" e901672f958b4ff39d4efb48290367e8 "," packa ge_state ":" staged "," health_check_timeout ": null," staging_failed_reason ": null," docker_image ": null," Package_updated_at ":" 2014-10-24T12: 53: 25 + 00: 00 "," space_url " : "/ V2 / space / 71a3c77f-d2791232323-4b7625dq32908492b04f17e", "stack_url": "/ v2 / heap / 71a3c77f-d2791232323 -4b7625dq32908492b04f17e", "events_url": "/ v2 / apps / 71a3c77f-d2791232323-4b7625dq32908492b04f17e / events" , "service_bindings_url": "/ v2 / apps / 7-4b7625dq32908492b04f17e / service_bindings", "routes_url": "/ v2 / apps / 771a3c77f-d2791232323-4b7625dq32908492b04f17e / routes"}}
< Code> So I have a URL ( / v2 / apps / 71a3c77f-d2791232323-4b7625dq32908492b04f17e ) that contains a summary of the information for a personal app i
to update the app resources on this URL HttpkPostform () I am using `(I'm aiming to update the number of Instenss for this app).
Fancy Update Interview (Token String) {tr: = & amp; Http.Transport {TLSClientConfig: This is to update the "Instance" resource of my code: & amp; Tls.Config {InsecureSkipVerify: true}} Customers: = & amp; http.Client {Transport: TR} request, hey: = client.PostForm ( "/ v2 / apps / 71a3c77f-d2791232323-4b7625dq32908492b04f17e", url.Values { "example": 4}) req.Header.Add ( "Authority" , Token) if mistake! = Zero {log. Fault (fault)} defer req.Body.Close ()}
This does not give me any errors but also does not update the resource.
type the values map [string] [] string
You can see that the value is
a map
which is like string
and < Code> [] string
request, oh :. = Client.PostForm ( "/ v2 / apps / 71a3c77f-d2791232323-4b7625dq32908492b04f17e", url.Values { "instances": 4})
So when you try a number It is fine, unless there is no [] string
of the value. Change it to
client.PostForm ("/ v2 / apps / 71a3c77f-d2791232324-4b7625dq32908492b04f17e", url.Values {"Example": {"4"}})
or you can do this
v: = url.Values {} v.Set ("Example", "4") client.PostForm ("
Comments
Post a Comment