0

This question already has an answer here:

@RestResource(urlMapping='/v/restAPIKeyGeneration/*')

global with sharing class APIforKeyGeneration{

    global class Account{
       public String sname;
       public String bp;

   }

    @HttpPost
    global static String CallTo(Account[] account,String sourceSystemID){
        system.debug('sourceSystemID');
        system.debug('rtrtr');
        return 'key' ;
    }
}

Guys, please help me,how to test this in postman,I used below to pass array but I also have to pass String

{
    "account": [{
        "sName": "REST Account"

    }, {
        "sName": "REST Account"

    }]
}

marked as duplicate by Himanshu, Tushar Sharma, Boris Bachovski, Vigneshwaran G, Sebastian Kessel Sep 21 '16 at 14:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

It just needs to be part of the JSON object.

{
    "account": [{
        "sName": "REST Account"

    }, {
        "sName": "REST Account"

    }],
    "sourceSystemID": "12345"
}

The key name should match the parameter name, and the value must be compatible with the destination data type (e.g. a Decimal expects an unquoted number, while a String requires quotes).

You may want to learn more about the JSON format.

0

I understand that sName is the standard name Account field but it is incorrect no need use the API name of the field, in this case is "Name":

Can you try this?

{
    "account": [{
        "Name": "REST Account"

    }, {
        "Name": "REST Account"

    }],
    "sourceSystemID": "12345"
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.