1 year ago
#241288
Shahriar
Refit REST library - Unable to post List<Guid> in Body
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
c#
rest
dotnet-httpclient
guid
refit
0 Answers
Your Answer