RPC Bad Request Error

Seeing if anyone has ever run into this Bad Request when trying to load an RPC? It loads fine when testing it in the RPC area but when using the URL in the module I get a Bad Request error

I think everything looks good on this, if possible can you share with me the IML code that you are using for it?

It should have worked regardless of, if you are getting the data in the RPC test.

1 Like

Hi @Runcorn

here is the one for get mailList

function getMailClasses(jsonData) {
  const mailClasses = jsonData.mailClasses || [];
  return mailClasses.map(mailClass => ({
    label: mailClass,
    value: mailClass
  }));
}

And here is the one for getting design fields

function getDesignFields(jsonData) {
  const output = [];
  const designFields = jsonData.designFields;
  for (let j = 0; j < designFields.length; j++) {
    const fieldKey = designFields[j].fieldKey;
    const fieldLabel = designFields[j].fieldLabel;
    const fieldType = designFields[j].fieldType;
    const mandatory = designFields[j].mandatory;
    let type, help;
    switch (fieldType) {
      case 'image':
        type = 'url';
        help = 'Insert the URL path to your image.';
        break;
      case 'text':
        type = 'text';
        break;
      default:
        type = fieldType;
    }
    output.push({ name: fieldKey, label: fieldLabel, type, required: mandatory, help });
  }
  // move required fields to the top
  output.sort((a, b) => {
    if (a.required && !b.required) return -1;
    if (!a.required && b.required) return 1;
    return 0;
  });
  return output;
}

Just these two that use IML are breaking the module… Thanks

Hi @scott74,

I completely missed this, did you resolve the issue or is it still there?

1 Like

@Runcorn Yes, I did, I had to nest the RPC on the dependent one for it to pick up. I thought I could hardcode in an ID just to test it out without nesting it but it did not like that.

Thanks

Heya @scott74 :wave:

Thanks so much for stepping back in here and sharing your solution with the community, much appreciated :pray:

Just FYI: I’m marking your last reply as a solution :white_check_mark:

1 Like