# Server to Server

**URL:** <https://forum.heroiclabs.com/t/server-to-server/250>\
**Category:** Local Setup\
**Created:** [October 1, 2019, 12:08pm UTC](https://forum.heroiclabs.com/t/server-to-server/250 "2019-10-01T12:08:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HashtagGo](https://avatars.discourse-cdn.com/v4/letter/h/dec6dc/32.png) [@HashtagGo](https://forum.heroiclabs.com/u/HashtagGo)\
**Post date:** [October 1, 2019, 12:08pm UTC](https://forum.heroiclabs.com/t/server-to-server/250/1 "2019-10-01T12:08:42Z")

</div>

I want to send object of custom struct in server to server request . but dont sucssessfully send object having error on rpc hook " unexpected end of JSON input"

This is my code outside nakama server

```
a := UpdateSpinningWheelValues{1,"test"}
showDownDAta, err := json.Marshal(a)
response, err := http.Post("http://127.0.0.1:7350/v2/rpc/http_handler_path?http_key=defaultkey", "application/json", bytes.NewBuffer(showDownDAta))
if err != nil {
	//handle error
} 

```

here is my code in nakama init module  
func HttpHandler(ctx context.Context, logger runtime.Logger, db \*sql.DB, nk runtime.NakamaModule, payload string) (string, error) {

```
	decoded := &UpdateSpinningWheelValues{}

	if err := json.Unmarshal([]byte(payload), &decoded); err != nil {
		logger.Printf("err is :: %v ", err)
	} else {
		logger.Printf("Index is :: %v ", decoded)
	}
return "testing http", nil 

```

}  
Error i get “unexpected end of json input in golang”

---

<div class="post-metadata">

**Author:** ![Superxwolf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/superxwolf/32/47_2.png) [@Superxwolf](https://forum.heroiclabs.com/u/Superxwolf)\
**Post date:** [October 1, 2019, 4:31pm UTC](https://forum.heroiclabs.com/t/server-to-server/250/2 "2019-10-01T16:31:52Z")

</div>

Hello @HashtagGo,

What version of Nakama server are you using?

---

<div class="post-metadata">

**Author:** ![HashtagGo](https://avatars.discourse-cdn.com/v4/letter/h/dec6dc/32.png) [@HashtagGo](https://forum.heroiclabs.com/u/HashtagGo)\
**Post date:** [October 2, 2019, 7:59am UTC](https://forum.heroiclabs.com/t/server-to-server/250/3 "2019-10-02T07:59:38Z")

</div>

Currently i’m using image of nakama 2.5.1

---

<div class="post-metadata">

**Author:** ![Superxwolf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/superxwolf/32/47_2.png) [@Superxwolf](https://forum.heroiclabs.com/u/Superxwolf)\
**Post date:** [October 2, 2019, 11:34am UTC](https://forum.heroiclabs.com/t/server-to-server/250/4 "2019-10-02T11:34:45Z")

</div>

Happened to me too, only Nakama 2.7 can receive raw json via RPC.

As a workaround for previous versions you can send the json as a string, to do that you must enclose the payload with quotes on the client side. On the server side the code should stay the same.

---

<div class="post-metadata">

**Author:** ![HashtagGo](https://avatars.discourse-cdn.com/v4/letter/h/dec6dc/32.png) [@HashtagGo](https://forum.heroiclabs.com/u/HashtagGo)\
**Post date:** [October 2, 2019, 11:37am UTC](https://forum.heroiclabs.com/t/server-to-server/250/5 "2019-10-02T11:37:31Z")

</div>

when i use this its work fine  
showDownDAta, err := json.Marshal(“a”) // workfine here  
response, err := http.Post(“[http://127.0.0.1:7350/v2/rpc/http\_handler\_path?http\_key=defaultkey](http://127.0.0.1:7350/v2/rpc/http_handler_path?http_key=defaultkey)”, “application/json”, bytes.NewBuffer(showDownDAta))  
if err != nil {  
//handle error  
}

but then send a struct its get an error  
a := UpdateSpinningWheelValues{1,“test”}  
showDownDAta, err := json.Marshal(a) //problem in this case  
response, err := http.Post(“[http://127.0.0.1:7350/v2/rpc/http\_handler\_path?http\_key=defaultkey](http://127.0.0.1:7350/v2/rpc/http_handler_path?http_key=defaultkey)”, “application/json”, bytes.NewBuffer(showDownDAta))  
if err != nil {  
//handle error  
}

---

<div class="post-metadata">

**Author:** ![Superxwolf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/superxwolf/32/47_2.png) [@Superxwolf](https://forum.heroiclabs.com/u/Superxwolf)\
**Post date:** [October 2, 2019, 11:41am UTC](https://forum.heroiclabs.com/t/server-to-server/250/6 "2019-10-02T11:41:13Z")

</div>

First one is just a string, which json converts to a quote enclosed string for the payload, the second one is a struct which converts to a json object. Just marshal the struct on the client side, then you must add quotes at the beggining and end for the Nakama gateway to interpret it as a string and allow it.

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [October 2, 2019, 1:42pm UTC](https://forum.heroiclabs.com/t/server-to-server/250/7 "2019-10-02T13:42:02Z")

</div>

@Superxwolf You’re right with older versions of Nakama (before 2.7.0) but in this release and all newer releases you can add `unwrap` as a query param to your server to server HTTP request so that it doesn’t need to be an escaped JSON string as input.

i.e.

```auto
"http://127.0.0.1:7350/v2/rpc/http_handler_path?http_key=defaultkey&unwrap=true"

```
