-
Hi, not sure if there is something I am missing here but I'm attempting to do GET branch/protection and then modify the response to then make a PUT to the same endpoint. When I do Example:
and then in the request I have to do this:
This is simple for the boolean types but isn't maintainable for the objects and the PUT requires atleast the following due to the error message I get when attempting to supply a partial request:
There must be something I'm missing here, a mapping method or am I simply approaching this the wrong way? Any help appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'm afraid there is not much we can do with the SDK to help. We just wrap the existing REST API endpoints, we are not changing them, with a very few exceptions. You can see the inconsistencies documented in the REST API here: https://developer.github.com/v3/repos/branches/#update-branch-protection. I'm afraid you will have to handle the inconsistencies yourself. One alternative would be to use GraphQL. I quickly checked, but it looks to me like the Yet another alternative would be to create an Octokit plugin which abstracts away these differences. I'm sure you are not the first to run into that problem, creating a reusable plugin might be useful for other people facing the same problem. Also if your project is private, you could make the plugin code public, which would allow me and others to collaborate on your code. Creating a reusable plugin is fairly simple: https://octokit.github.io/rest.js/v17#plugins. And I created an |
Beta Was this translation helpful? Give feedback.
I'm afraid there is not much we can do with the SDK to help. We just wrap the existing REST API endpoints, we are not changing them, with a very few exceptions. You can see the inconsistencies documented in the REST API here: https://developer.github.com/v3/repos/branches/#update-branch-protection. I'm afraid you will have to handle the inconsistencies yourself.
One alternative would be to use GraphQL. I quickly checked, but it looks to me like the
allowDeletions
settings is not enabled yet. You could check in with https://support.github.com/contact to ask about that.Yet another alternative would be to create an Octokit plugin which abstracts away these differences. I'm sure you are not …