Error utilizando una WebAPI para hacer delete de records

Certified Associate Developer

Buenas, tengo un problema y es que probando la webapi desde Appian directamente si me borra el registro que le paso por parámetro con id, pero estoy haciendo pruebas desde Postman para ver que funcionan las webapis de manera externa y cuando lanzo la de Delete me devuelve un 404 - Not Found y no hace nada, tengo otras webapis de tipo get y post que desde Postman me funcionan perfectamente con mis credenciales, no se si el problema estará en algún aspecto de la seguridad de la webapi de delete.

Muchas gracias de antemano

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    We would need a few more details about that API. Does that API check whether a valid value is passed and return a 404 if not?

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    This is the code of the API:

    a!localVariables(
    local!value: a!queryRecordType(
    recordType: 'recordType!{5c6be7a8-ccde-4a6c-81fe-1a328e67f94e}PA QueryRequest',
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50),
    filters: a!queryFilter(
    field: 'recordType!{5c6be7a8-ccde-4a6c-81fe-1a328e67f94e}PA QueryRequest.fields.{28bcd982-b3cc-434d-b7d6-1852f2472506}id',
    operator: "=",
    value: tointeger(http!request.queryParameters.id),
    applywhen: not(
    isnull(
    tointeger(http!request.queryParameters.id)
    )
    )
    )
    ).data,
    a!deleteRecords(
    records: local!value,
    /*
    * Construct an HTTP response to return to the caller
    */
    onSuccess: a!httpResponse(
    statusCode: 200,
    /*
    * Set an HTTP header that tells the client that the body of the response will be in JSON format
    */
    headers: {
    a!httpHeader(
    name: "Content-Type",
    value: "application/json"
    )
    },
    ),
    onError: a!httpResponse(
    statusCode: 500,
    headers: {
    a!httpHeader(
    name: "Content-Type",
    value: "application/json"
    )
    },
    body: a!toJson(
    a!map(
    message: "Delete request has failed",
    error: fv!error
    )
    )
    )
    )
    )

    The API only asks for the id of the record to delete

  • 0
    Certified Lead Developer
    in reply to adolfo.rodriguez

    Interesting implementation. What would happen when I do not pass an ID?

    So the API does not return a 404. For me this looks like a problem in the postman setup.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    Shouldn't be a problem with the postman setup, I'm using the same credentials to do another queries of type get and post and there is no problem with them. Got that I need to control if no id is passed, will implement it but anyways that's not related with the problem I have.

  • 0
    Certified Lead Developer
    in reply to adolfo.rodriguez

    Buenas Adolfo,

    Cuando una web api te devuelve un 404, suele estar relacionado con un problema de seguridad. Asegurate que estas pasando las credenciales correctamente (dependiendo de si estas usando basic o un API KEY para mapear contra un cuenta de servicio)

    Si como comentas, te funciona de la misma forma con otras web apis, es posible que sea porque falte por añadir tu usuario al grupo con permisos sobre esta nueva que has creado . ¿Puedes chequearlo por favor?

  • 0
    Certified Associate Developer
    in reply to David J (NTT DATA)

    Buenos días David, para la aplicacion solo existen dos grupos creados, uno de Administradores y otro de Users, mi usuario está en el grupo de Administradores por lo que tiene acceso a todo, incluso a lanzar cualquiera de las APIs, entiendo que con eso ya debería funcionar, no sé si por culpa de que sea una API de tipo DELETE cambia algo a la hora de seguridad pero en principio la API y su seguridad siguen la misma línea que el resto, el grupo Administradores de la aplicación tiene permisos de Administrador para cada API creada

  • 0
    Certified Lead Developer
    in reply to adolfo.rodriguez

    Prueba a hacer la petición a la web api desde postman para ver si te funciona correctamente.

Reply Children