API Connect

 View Only
  • 1.  Validate policy not working APIConnect v10

    Posted Mon August 28, 2023 11:00 AM

    Here is our scenario. 

    We have added an API by importing OpenAPI 3.0 specification yaml file. We would like to validate the incoming message against the message definition. We are trying to use the validate policy. We configured the policy to validate the incoming JSON message against Definition and then selected the required definition from the dropdown menu. 

    We get below error - 

    {"httpCode":"400","httpMessage":"Bad Request","moreInformation":"Validate: Instance is neither parsed XML, parsed JSON nor parsed GraphQL"}

    Is there anything wrong that we are doing ? Did we miss anything? 



    ------------------------------
    Sandeepkumar Rane
    ------------------------------


  • 2.  RE: Validate policy not working APIConnect v10

    Posted Mon August 28, 2023 05:28 PM

    Hi Sandeepkumar,

    Do you have a parse policy as your first assembly policy?  request.body is unparsed which would be causing this type of error.  message.body will be created by the parse policy and will be consumed by the validate policy.
    Best Regards,

    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 3.  RE: Validate policy not working APIConnect v10

    Posted Thu August 31, 2023 05:22 PM

    Thank  you Steve. It is working as expected. 



    ------------------------------
    Sandeepkumar Rane
    ------------------------------



  • 4.  RE: Validate policy not working APIConnect v10

    Posted 23 days ago

    Hi steve,

    could you advise ,I used parse assembly with these configurations :

    while it returns this error in the logs :  For Assembly Action 'switch-sit-env_sit-catalog_mw_chld_get_virt_card_denom_1.0.0_parse_0', cannot find the specified variable 'request.body' in the API context. 

     

    version: 2.0.0
        title: Parse JSON Payload
        description: Parses the incoming JSON payload
        use-content-type: true
        document_type: JSON
        input: request.body
        output: parsedPayload


    ------------------------------
    Basma Hesham
    ------------------------------



  • 5.  RE: Validate policy not working APIConnect v10

    Posted 23 days ago
    Edited by Steve Linn 23 days ago

    Hi Basma,
    The parse policy only needs the API Gateway context message name.  It will use on input or create on output the .body, so simply remove the .body:

    version: 2.0.0
        title: Parse JSON Payload
        description: Parses the incoming JSON payload
        use-content-type: true
        document_type: JSON
        input: request
        output: parsedPayload

    Your input will be read from request.body and your output will be written to parsedPayload.body

    Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------