Questions tagged [http4s-circe]
18 questions
                    
                    14
                    
            votes
                
                2 answers
            
        Add json body to http4s Request
This tut shows how to create an http4s Request: https://http4s.org/v0.18/dsl/#testing-the-service
I would like to change this request to a POST method and add a literal json body using circe. I tried the following code:
val body =…
        
        Herman J. Radtke III
        
- 1,804
 - 1
 - 24
 - 29
 
                    7
                    
            votes
                
                1 answer
            
        Circe Encoders and Decoders with Http4s
I am trying to use http4s, circe and http4s-circe. 
Below I am trying to use the auto derivation feature of circe.
import org.http4s.client.blaze.SimpleHttp1Client
import org.http4s.Status.ResponseClass.Successful
import io.circe.syntax._
import…
        
        Knows Not Much
        
- 30,395
 - 60
 - 197
 - 373
 
                    5
                    
            votes
                
                1 answer
            
        Http4s Client Encode Entity as x-www-form-urlencoded Recursively
I have a request like the following
val request =
    Request[IO](
      method = POST,
      uri = Uri.uri("..."),
      headers = Headers(
        Authorization(BasicCredentials("...", "..."))
      )
    )
   …
        
        sinanspd
        
- 2,589
 - 3
 - 19
 - 37
 
                    5
                    
            votes
                
                1 answer
            
        Scala: http4s giving 401 Unauthorized for same request that works in curl/requests
I tried the following code using http4s v0.19.0:
import cats.effect._
def usingHttp4s(uri: String, bearerToken: String)(implicit cs: ContextShift[IO]): String = {
    import scala.concurrent.ExecutionContext
    import org.http4s.client.dsl.io._
  …
        
        pathikrit
        
- 32,469
 - 37
 - 142
 - 221
 
                    4
                    
            votes
                
                0 answers
            
        PostgreSQL Error with Doobie: PSQLException: The column index is out of range: 3, number of columns: 2
I am practicing with Scala, Doobie and PostgreSQL. The database is within a Docker container. I am able to post and update jobs but unable to GET all posts. I keep getting the below error.
I have researched other similar questions but my differs as…
        
        Ry2254
        
- 859
 - 1
 - 10
 - 19
 
                    4
                    
            votes
                
                2 answers
            
        Http4s EntityDecoder not being auto derived for simple case class
I am getting this error:
Cannot decode into a value of type com.blah.rest.model.UserProfile, 
because no EntityDecoder[cats.effect.IO, com.blah.rest.model.UserProfile] 
instance could be found.
for the following case class:
case class…
        
        iyerland
        
- 632
 - 2
 - 10
 - 24
 
                    2
                    
            votes
                
                1 answer
            
        Http4s decoder how to customize error message for invalid fields
I have following code like:
 case req @ POST -> Root =>
        req
          .decode[UserCreateRequest] { decodedRequest =>
my stack is http4s + zio.
Ive added custom decoder for this case class where I have a line:
email <-…
        
        FrancMo
        
- 2,459
 - 2
 - 19
 - 39
 
                    2
                    
            votes
                
                0 answers
            
        Getting 403 forbidden error in Get request using http4s
I am doing a short assignment in http4s and I am getting 403 error from a long time which is difficult to debug. My code is:
object Assignment extends App {
  implicit val cs: ContextShift[IO] = IO.contextShift(global)
  implicit val timer:…
        
        harshul dang
        
- 21
 - 3
 
                    2
                    
            votes
                
                1 answer
            
        Encoding recursive data structure into Json with Circe when running on http4s
I am building a very simply service, that should return a tree like structure defined through a recursive case class:
case class Node(id: Int, name: String, children: Seq[Node] = Seq())
But for some reason I keep getting a following compilation…
        
        singleton
        
- 326
 - 2
 - 13
 
                    1
                    
            vote
                
                1 answer
            
        How to decode array containing json with Circe
I have my circe Decoder as shown below. I am confident my Sentiment Decoder works correctly so won't include it below.
case class CryptoData(value: String, valueClassification: Sentiment)
  implicit val decoder: Decoder[CryptoData] =…
        
        Ry2254
        
- 859
 - 1
 - 10
 - 19
 
                    1
                    
            vote
                
                1 answer
            
        Http4s circe can not decode children
I have error model like:
sealed trait HttpError {
    val msg: String
    val cause: String
  }
  final case class HttpDecodingError(cause: String) extends HttpError {
    override val msg: String = "Decoding error"
  }
  final case class…
        
        FrancMo
        
- 2,459
 - 2
 - 19
 - 39
 
                    1
                    
            vote
                
                1 answer
            
        Need help decoding following json with Circe
I'm trying to parse nested JSON object with Circe library. I would like to map it to flat case class ignoring some of the fields.
import io.circe.generic.auto._
import io.circe.{Decoder, Encoder, HCursor, Json}
val jsonString = """{
  "parent" : {
…
        
        marcin_koss
        
- 5,763
 - 10
 - 46
 - 65
 
                    0
                    
            votes
                
                1 answer
            
        Decode a list of IO[Int] in http4s when returning value in response
I am currently trying to write extension for external API using http4s Client and Server tools.
My idea was: when endpoint, which I created using Server is triggered, make multiple requests (to same endpoint on external API, but with different…
        
        Alexey Gavrilik
        
- 1
 - 2
 
                    0
                    
            votes
                
                0 answers
            
        Get a Stream of Entity from an Http4s Response with Circe
I'm trying to retrieve a Stream[IO, Job] from an http4s Response, but the Scala compiler warns me that it cannot find any suitable Decoder:
Cannot decode into a value of type fs2.Stream[IO,Job], because no EntityDecoder[[+A]IO[A],…
        
        riccardo.cardin
        
- 7,971
 - 5
 - 57
 - 106
 
                    0
                    
            votes
                
                1 answer
            
        Circe decoder-encoder for object as json parameter type
How to write such a string-encoder decoder for circe?
For example, I have
case class Something (s: String, foo: Foo, bar: Bar)
where Bar is member of ADT
trait Bar
case object A extends Bar
case object B extends Bar
where I want to decode my…
        
        Ostap Strashevskii
        
- 109
 - 1
 - 8