softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.45k stars 304 forks source link

Missing content type on Multipart #2188

Closed kry00la closed 4 months ago

kry00la commented 4 months ago

Hello Just wanted to confirm if this is a bug that I found in sttp v1.7.x

I'm trying to send a request with Multipart using the snippets bellow

sttp
      .post(uri"$uri")
      .multipartBody(
        Seq(
          Multipart("message", StringBody(requestBody.asJson.noSpaces,"UTF-8", Some(Json)), contentType = Some(Json)).contentType(Json),
          Multipart(name = "attachment",
            body = ByteArrayBody(attachment.file), fileName = Some(attachment.fileName)).fileName(attachment.fileName)
        )
      )

However I have been receiving a 415 UNSUPPORTED_MEDIA_TYPE from the service; When I try investigating I found that the value of the content type on the parts of Multipart request are null.

SCR-20240521-gde

Also I found here that we are adding null values to it. Is this a known issue from this version?

adamw commented 4 months ago

To be honest - I don't know. The last release of v1 was 5 years ago. It's quite possible that it is a bug in that version, though it is not longer maintained, so I think the best solution would be to migrated to a newer one.

kry00la commented 4 months ago

Thanks @adamw ; this is my next step just wanted to confirm and see if are there official work around :)