Home > front end >  .NET Core API - Send array of object as FormData via Postman
.NET Core API - Send array of object as FormData via Postman

Time:02-11

How can I send an array of objects through postman using form-data?

Object

public class Relations
{
    public short RelationTypeID { get; set; } = 0;
    public List<UserMessageType> UserList { get; set; } = new List<UserMessageType>();
}

public class UserMessageType
{
    public int UserId { get; set; }
    public short MessageTypeID { get; set; }

    public string UserEmailAddress { get; set; } = string.Empty;
}

I do not know how can I send a list of Relations through Postman. I read somewhere that I can write multiple Relations but what about child objects. I tried the following on Postman. This is the bulk edit version of the form

ConversationID:0
Relations:[{RelationTypeID:1,UserList:[{UserId:15,MessageTypeID:1}]}]

This is another try

ConversationID:0
Relations:RelationTypeID:1, UserList: UserId:15,MessageTypeID:1

CodePudding user response:

To post via form-data, you can't straight send the value with object nor array.

You can import the below cURL script to Postman by following enter image description here

Debugging Output in Visual Studio

enter image description here

  • Related