Hi,

here is a simple snippet that does that:

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.marshalling.Marshaller._
import akka.http.scaladsl.model._
import akka.stream.ActorMaterializer

import scala.concurrent.Future

object HttpClientFormData extends App {

  implicit val sys = ActorSystem("HttpClientFormData")
  implicit val mat = ActorMaterializer()
  implicit val exc = sys.dispatcher

  val uri = Uri("http://localhost:8080/HYzYYhcOxrhIxsezap3U";)
  val data = Map("session.id" -> "123", "name" -> "john")

  val request: Future[HttpRequest] = Marshal((HttpMethods.POST, uri,
FormData(data))).to[HttpRequest]
  val response: Future[HttpResponse] =
request.flatMap(Http().singleRequest(_))
  response.onComplete(println)
}

You can read up on Marshalling
<https://doc.akka.io/docs/akka-http/10.0.10/scala/http/common/marshalling.html>
to
get a better feel of how the tuple of the HTTP method, uri and formdata got
converted to HttpRequest.

Also for the HTTPS you will need some additional configuration. You can
find a working HTTPS server and a client example here:
https://github.com/2m/akka-http/commit/6562550ca495cb209b5c05957c2303f99ff7b60c



On Thu, Nov 16, 2017 at 5:56 AM <vishal.ve...@exadatum.com> wrote:

> I am working with a use case where I need to make a call to Azkaban via
> AJAX APi provided by Azkaban which is like
>
> curl -k -X POST --data 
> "session.id=9089beb2-576d-47e3-b040-86dbdc7f523e&name=aaaa&description=11"
> https://localhost:8443/manager?action=create
>
> Now how using akka HTTP rest services can I send a payload with --data
> parameter ie --data 
> "session.id=9089beb2-576d-47e3-b040-86dbdc7f523e&name=aaaa&description=11"
> part
> what is the proper approach to do this.
>
>
>
>
>
>
> *DISCLAIMER:*
> All the content in email is intended for the recipient and not to be
> published elsewhere without Exadatum consent. And attachments shall be send
> only if required and with ownership of the sender. This message contains
> confidential information and is intended only for the individual named. If
> you are not the named addressee, you should not disseminate, distribute or
> copy this email. Please notify the sender immediately by email if you have
> received this email by mistake and delete this email from your system.
> Email transmission cannot be guaranteed to be secure or error-free, as
> information could be intercepted, corrupted, lost, destroyed, arrive late
> or incomplete, or contain viruses. The sender, therefore, does not accept
> liability for any errors or omissions in the contents of this message which
> arise as a result of email transmission. If verification is required,
> please request a hard-copy version.
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to