# Server Side Swift with Vapor - Part 4: Accepting Data | Ray Wenderlich

**URL:** <https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465>\
**Category:** 🎓 Courses & Articles\
**Created:** [February 14, 2018, 5:04pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465 "2018-02-14T17:04:23Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![amyerson](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@amyerson](https://forums.kodeco.com/u/amyerson)\
**Post date:** [March 22, 2018, 10:19am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/21 "2018-03-22T10:19:51Z")

</div>

Worked like a charm, thanks!

---

<div class="post-metadata">

**Author:** ![gsequeira](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gsequeira/32/100331_2.png) [@gsequeira](https://forums.kodeco.com/u/gsequeira)\
**Post date:** [March 26, 2018, 11:10am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/22 "2018-03-26T11:10:21Z")

</div>

@0xtim I receive a `Use of undeclared type "InfoResponse"` compiler error when using the new way.

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 26, 2018, 11:49am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/23 "2018-03-26T11:49:23Z")

</div>

@gsequeira do you have an `InfoResponse` struct yet in your code? If you are on the first part and you returning a string it would look like:

```swift
router.post(InfoData.self, at: "info") { req, data -> String in
  return "Hello \(data.name)!"
}

```

---

<div class="post-metadata">

**Author:** ![gsequeira](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gsequeira/32/100331_2.png) [@gsequeira](https://forums.kodeco.com/u/gsequeira)\
**Post date:** [March 26, 2018, 12:00pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/24 "2018-03-26T12:00:59Z")

</div>

Still on the first part. Thanks.

---

<div class="post-metadata">

**Author:** ![marko\_kovac](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/marko_kovac/32/102075_2.png) [@marko\_kovac](https://forums.kodeco.com/u/marko_kovac)\
**Post date:** [April 1, 2018, 7:36pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/25 "2018-04-01T19:36:19Z")

</div>

This has been helpful, maybe Ray Wenderlich team could implement annotations that point to these comments in cases like these ?

---

<div class="post-metadata">

**Author:** ![nevwild](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nevwild/32/93378_2.png) [@nevwild](https://forums.kodeco.com/u/nevwild)\
**Post date:** [April 1, 2018, 8:53pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/26 "2018-04-01T20:53:59Z")

</div>

That would be awesome.

---

<div class="post-metadata">

**Author:** ![nevwild](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nevwild/32/93378_2.png) [@nevwild](https://forums.kodeco.com/u/nevwild)\
**Post date:** [April 1, 2018, 9:21pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/27 "2018-04-01T21:21:39Z")

</div>

This gist has all the code changes caused by the recent update.

> <https://gist.github.com/0xTim/b372f91c8bd71ea757d1da526058f2d9>

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 5, 2018, 4:46pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/29 "2018-08-05T16:46:44Z")

</div>



---

<div class="post-metadata">

**Author:** ![saiy](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@saiy](https://forums.kodeco.com/u/saiy)\
**Post date:** [December 18, 2018, 6:32am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/30 "2018-12-18T06:32:16Z")

</div>

I still dont get the code in CRUD operations working after installing the latest version of Vapor 3.0.0 and the changes suggested here

> <https://gist.github.com/0xTim/b372f91c8bd71ea757d1da526058f2d9>

Please help

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [December 18, 2018, 10:57am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/31 "2018-12-18T10:57:08Z")

</div>

What errors are you getting? I’m currrntly re-recording the videos so updated ones should be available in the new year!

Also check out [GitHub - raywenderlich/vapor-til: The TIL Application for the Vapor book](https://github.com/raywenderlich/vapor-til) which is from the book, but builds on everything from the videos. Should help point you in the right direction

---

<div class="post-metadata">

**Author:** ![saiy](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@saiy](https://forums.kodeco.com/u/saiy)\
**Post date:** [December 18, 2018, 11:55am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/32 "2018-12-18T11:55:50Z")

</div>

For example, I havent been able to implement the updateHandler method as described in vapor-til repo from git hub. But I implemented it the followign way that returns the Acronym that is updated instead of HTTPStatus. I couldnt get the flapMap to return HTTP Status.

func updateHandler(\_ req: Request) throws → Future {  
return try flatMap(to: Acronym.self, req.parameters.next(Acronym.self), req.content.decode(Acronym.self)) { acronym, updateData in  
acronym.short = updateData.short  
acronym.long = updateData.long  
return acronym.save(on: req)  
}  
}

Now I m stuck in searchHandler. The code given in the repo complains “Type of expression is ambiguous without more context” build error for the query method with filter. I am struggling to fix that.

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [December 18, 2018, 1:04pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/33 "2018-12-18T13:04:51Z")

</div>

So if you’re returning `HTTPStatus` you’d need to do something like:

```swift
func updateHandler(_ req: Request) throws -> Future<HTTPStatus> {
  return try flatMap(to: HTTPStatus.self, req.parameters.next(Acronym.self),  
                                 req.content.decode(Acronym.self)) { acronym, updateData in
    acronym.short = updateData.short
    acronym.long = updateData.long
    return acronym.save(on: req).transform(to: .ok)
  }
}

```

For the search handler, have you imported Fluent?

---

<div class="post-metadata">

**Author:** ![saiy](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@saiy](https://forums.kodeco.com/u/saiy)\
**Post date:** [December 18, 2018, 1:10pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/34 "2018-12-18T13:10:37Z")

</div>

Thanks, the import was the issue for search Handler. However I am now stuck in MySQL when the FLuentMySQL is giving build errors. Can you please let me now if I am missing any configuration? I have set the -DNOJSON as instructed in some other thread in stack overflow but no luck

/FluentMySQL/MySQLType.swift:3:30: Use of undeclared type ‘MySQLDataTypeStaticRepresentable’

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [December 19, 2018, 8:21pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/35 "2018-12-19T20:21:35Z")

</div>

Try running `swift package update` to get the latest code and doing a clean

---

<div class="post-metadata">

**Author:** ![saiy](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@saiy](https://forums.kodeco.com/u/saiy)\
**Post date:** [December 21, 2018, 6:02am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/36 "2018-12-21T06:02:48Z")

</div>

Hi Tim, Thanks for the info, the update solved my problems but for some strange reason the connection is not allowed to the MySQL server created by docker.

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [December 21, 2018, 1:37pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/37 "2018-12-21T13:37:36Z")

</div>

What error are you getting?

[Previous page](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465.md?page=1)
