0

I'm unable to post List through refit. Here's the interface declaration:

[Post("/api/Url/{id}")]
[Headers("Content-Type:application/json")]
Task<Model> PostMethod([Body(BodySerializationMethod.UrlEncoded)] CommandType command)

Here's the CommandType class

public class CommandType
{
    public IEnumerable<Guid> Prop { get; set; }
}

Even though Refit is able to make the call but the argument for Prop is null at the receiving end.

[UPDATE] I tried with [Body(BodySerializationMethod.UrlEncoded)] [Query(CollectionFormat.Multi)] too but no luck!

[FOUND SOLUTION] I've solved it using just the following by removing both Body attribute and CommandType. Instead, put the Property inside the class into the parameter directly. Just FYI.

[Query(CollectionFormat.Multi)] IEnumerable of Guid for Prop

Shahriar
  • 1
  • 2
  • `IEnumerable` is not `List`. – Dai Mar 02 '22 at 05:28
  • 1
    And how the receiving end does look? Also using `BodySerializationMethod.UrlEncoded` with `Headers("Content-Type:application/json")` looks a bit suspicious to me. – Guru Stron Mar 02 '22 at 06:20
  • The receiving end defines it as IEnumerable but I tried with List without much luck. Receiving end has the CommandType as parameter but it's received as null. Receiving end is just a POST method implementation. I tried without Headers too but without any luck. – Shahriar Mar 02 '22 at 06:32

0 Answers0