Applying suggestions - where to get id

Applying suggestions - where to get id


I’m preparing framework in SoapUI for GitLab’s REST API and got blocked on one of endpoints. I couldn’t find anything suitable on google or here, so any help or link would be appreciated.

Endpoint: /suggestions/:id/apply
Request: PUT
Auth: private-token in header and oauth2

And finally the question: where/how can I check the ID of the suggestion?
If I try random IDs, some will return 404 (so no such suggestion) and some 403 (so those are in projects that i don’t have dev+, I guess).
I’ve created suggestion in merge request in one of my projects (private) and tried to find it there in the page’s code. The only thing that seemed suitable was ID of the note (note_332089796). I’ve tried whole string, just int and some other combinations, but every time 404 was returned.
Maybe I am missing something and this endpoint is not meant for such usage? Or maybe it’s just for administrative users (however, it should have been mentioned in the docs in such case)?



Hey, do you mind granting permission to view your repository? I think I know how to get the suggestion ID. Frankly I don’t even know what suggestions are and how they work (at least I don’t know them by that name?), but I’m quite sure I am able to help you out.

My GL nickhandle is aljaxus.

I you decide not to grant me permission to view the suggestion in your repo, please provide another public repository with such code suggestion in a PR. I just need a live example.

Kind regards.

Thank you, invitation sent. It’s just a dummy project.
Here is the suggestion I was trying with:

Yup. Just got the email, checked if I was right (and as expected, I was :stuck_out_tongue: )

You can get the suggestion ID in the discussions array. I don’t know the exact API requests, but I can describe to you where you can find it and then you can go on from there :wink:

  1. Open browser dev tools and go to “network” tab
  2. select the “xhr” filter, so you get rid of all other requests (easier to find the exact request)
  3. Open the MR page
  4. find the request fired against${namespace}/${project}/-/merge_requests/${MR.ID}/discussions.json ( in our case )
  5. Find the reply that includes the suggestion you are searching for (8th. in this case; id 8e964b05803dd8702040f388557da2ec44cd4710 )
  6. Now just find the suggestions property in the note object in the notes array in the reply object :stuck_out_tongue: (this in that in that in this in this other thing which is located over there in the part that has another thingy)

Nice! Now you know what the suggestion ID looks like and some other data that you weren’t able to get from the docs (such are relations to other objects, etc…)

I suppose that you can fetch the suggestion object via MR API namespace.

Have a nice day :wave: (and mark this reply as the solution to your problem >:] ! )
or just ask if you have any other questions :wink:

1 Like

Wow, that one was tricky. Thank you very much. Have a nice day. :slight_smile:

1 Like