C
C#17mo ago
ayman23

❔ sending multiple object json via API

Hello developers, i am Ayman I am working on a project implementing api inside my web app mvc 5 but I'm struggling to send multiple object json via the api. I need to know specifically how to send a json containing a model instance and a string. Any help or advice would be appreciated
4 Replies
ayman23
ayman23OP17mo ago
When i send only the model instance the api request works but not when i try sending the string aswell
artya
artya17mo ago
Can you return a Dto containing the model and the string?
Pobiega
Pobiega17mo ago
You can only send one thing. So what you do when you need to send multiple things is make a new thing that contains all the things you want. As artya said, create a dto like
public record ResponseDto(Model model, string str);
public record ResponseDto(Model model, string str);
and return an instance of that
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server