Updating a Forge-based custom field using the API results in "OAuth 2.0 is not enabled"

Hey folks,

I am trying to set the value of a custom field created with a Forge app. My code runs inside of a trigger function and looks like this; it’s virtually identical to the example from the documentation.

          const res = await api.asApp().requestJira(route`/rest/api/3/app/field/LONG_FIELD_ID/value`, {
            method: 'POST',
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json'
            },
            body: updateData
          });

However, I always get this error:

INFO    __  Response: 403 Forbidden
INFO    __  { errorMessages: [ 'OAuth 2.0 is not enabled for this method.' ] }

Now, I’d be happy to use another form of authentication, but this being a Forge trigger, api.asApp() is the only option I know. Additionally, the documentation specifically states:

This resource represents the values of custom fields added by Forge apps. Use it to update the value of a custom field on issues.

So, am I missing something here?

Thanks,
Oliver

1 Like

Hey @osiebenmarck,

it’s virtually identical

Well, it needs to be literally identical. The path is rest/api/3/app/field/field/value (“field” verbatim, not your field ID).

1 Like

Hi @kkercz ,

Thanks for answering and sorry that I somehow missed your answer until now.

I have gotten it to work by now using a different endpoint and the following code:

    const res = await api.asApp().requestJira(route`/rest/api/3/app/field/value`, {
        method: 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
        body: updateData
      });

Note, that this only includes field once.

The other endpoint I tried before does use the field ID in the URL, however it needs a PUT request as opposed to a POST.

So, long story short: If you put your field ID in the URL, you’ll need PUT, if you put it in the body, then that’s a POST.

1 Like