title: Scala (Spray/Akka) : The request content was malformed: an implementation is missing
body: <p>I have a problem using Spray to get the post body:</p>
  
  <p>When I send in a Json call I get "The request content was malformed: an implementation is missing"</p>
  
  <p>The Json I send is the Json created in the request (val test)
  As mentioned in the code I got the implementation from <a href="https://stackoverflow.com/questions/21756836/providing-a-jsonformat-for-a-sequence-of-objects">Providing a JsonFormat for a Sequence of Objects</a></p>
  
  <p><strong>CreateOrder.Scala</strong></p>
  
  <pre><code>import spray.json._
  import spray.httpx.unmarshalling._
  import spray.httpx.marshalling._
  
  
  case class CreateOrder (order_number: String,
                          order_source_code: String,
                          created_order_date: String,
                          shipping_address: String,
                          payment_method: String,
                          customer_name: String,
                          customer_tel: String,
                          customer_postcode: String,
                          customer_email: String,
                          ob_zone: String,
                          order_line_items: Seq[Order_Line_Items]
                          )
  case class Order_Line_Items (order_line_item_number: String,
                                             sku_number: String,
                                             item_name: String,
                                             paid_price: String
                                            )
  
  //Source : https://stackoverflow.com/questions/21756836/providing-a-jsonformat-for-a-sequence-of-objects
  object CreateOrderProtocol extends DefaultJsonProtocol {
     implicit object OrderItemsFormat extends RootJsonFormat[Order_Line_Items] {
      def write(oli: Order_Line_Items) = JsObject(Map(
        "order_line_item_number" -&gt; JsString(oli.order_line_item_number),
        "sku_number" -&gt; JsNumber(oli.sku_number),
        "item_name" -&gt; JsString(oli.item_name),
        "paid_price" -&gt; JsString(oli.paid_price)
      ))
      def read(value: JsValue): Order_Line_Items = ???
    }
    implicit object CreateOrderFormat extends RootJsonFormat[CreateOrder] {
      def write(order: CreateOrder) = JsObject(Map(
        "order_number" -&gt; JsString(order.order_number),
        "order_source_code" -&gt; JsString(order.order_source_code),
        "created_order_date" -&gt; JsString(order.created_order_date),
        "shipping_address" -&gt; JsString(order.shipping_address),
        "payment_method" -&gt; JsString(order.payment_method),
        "customer_name" -&gt; JsString(order.customer_name),
        "customer_postcode" -&gt; JsString(order.customer_postcode),
        "customer_email" -&gt; JsString(order.customer_email),
        "ob_zone" -&gt; JsString(order.ob_zone),
        "order_line_items" -&gt; JsArray(order.order_line_items.map(_.toJson).toList)
      ))
      def read(value: JsValue): CreateOrder = ???
    }
  }
  </code></pre>
  
  <p><strong>Main.Scala</strong></p>
  
  <pre><code>path("dev" / "order" / "create") {
          headerValueByName("AppId") { appId =&gt;
            headerValueByName("AppSecret") { appSecret =&gt;
              post {
              entity(as[CreateOrder]){ req =&gt;
                  respondWithMediaType(`application/json`) {
                    complete{
                       val test = new CreateOrder("1","2","3","4","5","6","7","8","9","10",Seq( new Order_Line_Items("11","12","13","14"), new Order_Line_Items("21","22","23","24") ) )
                      if(elasticCaller.api_check(appId,appSecret)){
                          val reply = Map("Status"-&gt;"Success")
                          ModelConverter.fromAnyToJson(test)
                      }else{
                          val reply = Map("Status"-&gt;"Failed")
                          ModelConverter.fromAnyToJson(test)
                      }
                    }
                  }
                }
              }
            }
          }
        }
  </code></pre>