-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snipe IT Hardware API PATCH/PUT doesn't update text fields with null or blank value. #6113
Comments
Is this still relevant? We haven't heard from anyone in a bit. If so, please comment with any updates or additional detail. |
Yes, it's still relevant. |
Okay, it looks like this issue or feature request might still be important. We'll re-open it for now. Thank you for letting us know! |
I'm running in to the same issue with this. Have there been any updates on this? I need to blank out a field via the API but it seems to ignore blank or null updates. |
The problem with the API is that it's using a completely separate code path. Which leads to duplicated code to do the same things. The backend processing should really be merged. I don't really understand why they're different. If you watch the network requests that your browser makes when updating objects you can see that they request content is almost identical to what's required for the APIs. For example take a look at the User controller for web requests and the one for api requests. Aside from the method of confirming authorization to perform the update (which should be abstracted elsewhere in the program) and the returned response the actions these functions perform should ostensibly be the same. Hopefully this problem can get rectified in the future. |
Because building a REST API takes time, and you don't get a lot of opportunity to change your mind once people start using it. We had the option of releasing it in steps, or making people wait to get anything at all, and we opted to release it in steps. It's not that complicated to understand.
Pull requests are always welcome. |
…ia API Need to confirm that re-enabling `\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,` won’t mangle anything. I know we ran into some issues when testing a long time ago, but not sure thos issues apply anymore, and I can’t remember what they were.
@nhut @ryan3anderson I've just pushed out a possible fix for this issue. Can you pull that feature branch and see if that resolves it for you? |
I tried a moment ago and it gives http 500 internal server error (html page). Is the change at https://develop.snipeitapp.com ? |
Please confirm you have done the following before posting your bug report:
Describe the bug
Snipe IT Hardware API PATCH/PUT doesn't update text fields with null or blank value for example "name", "serial", "notes", custom field strings...
To Reproduce
Step 1. Let's start with updating hardware name value to "hardware name".
URL: https://develop.snipeitapp.com/api/v1/hardware/16
Http method: PATCH
Request body content:
And we get API response with body content:
Step 2. Update hardware name value to "".
URL: https://develop.snipeitapp.com/api/v1/hardware/16
Http method: PATCH
Request body content:
And we get API response:
Expected behavior
name-field value should be updated to "" and API should respond with:
Server (please complete the following information):
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: