Skip to content
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

No OData route exists that match template - deviceManagement/assignmentFilters #443

Open
ShocOne opened this issue Jul 25, 2024 · 0 comments
Assignees
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@ShocOne
Copy link

ShocOne commented Jul 25, 2024

Describe the bug

Hi there, i am writing a terraform provider on top of your SDK. My work initially is starting with a simple object to test the provider with. I have chosen graph beta deviceManagement/assignmentFilters.

I have successfully implemented all of the CRUD functions for this resource apart from the update function which gives me errors i believe related to the SDK. The full set of crud function can be found here.

I am trying to update resources once created using the http PATCH method as follows:

// Update handles the Update operation.
func (r *AssignmentFilterResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
	var plan AssignmentFilterResourceModel

	tflog.Debug(ctx, fmt.Sprintf("Starting Update of resource: %s_%s", r.ProviderTypeName, r.TypeName))

	resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
	if resp.Diagnostics.HasError() {
		return
	}

	updateTimeout, diags := plan.Timeouts.Update(ctx, 30*time.Second)
	resp.Diagnostics.Append(diags...)
	if resp.Diagnostics.HasError() {
		return
	}
	ctx, cancel := context.WithTimeout(ctx, updateTimeout)
	defer cancel()

	requestBody, err := constructResource(ctx, &plan)
	if err != nil {
		resp.Diagnostics.AddError(
			"Error constructing assignment filter",
			fmt.Sprintf("Could not construct resource: %s_%s: %s", r.ProviderTypeName, r.TypeName, err.Error()),
		)
		return
	}

	_, err = r.client.DeviceManagement().AssignmentFilters().ByDeviceAndAppManagementAssignmentFilterId(plan.ID.ValueString()).Patch(ctx, requestBody, nil)
	if err != nil {
		common.HandleUpdateStateError(ctx, resp, r, &plan, err)
		return
	}

	resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...)

	tflog.Debug(ctx, fmt.Sprintf("Finished Update Method: %s_%s", r.ProviderTypeName, r.TypeName))
}

My issue i believe this is due to incorrect URL construction. Is this something occurring at the SDK level, or am i incorrectly constructing my call with the PATCH method ? Any help appreciated.

thank you

Expected behavior

A well form PATCH request should be sent and update the resource via graph

How to reproduce

Go to provider, compile, create a resource using example from examples folder in HCL. Then change an attribute of the deviceAssignmentFiler and run terraform apply.

SDK Version

v0.106.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log i get the following error returned ``` 2024-07-25T19:53:34.109+0100 [ERROR] vertex "microsoft365_graph_beta_device_and_app_management_assignment_filter.example" error: Error updating resource


│ Error: Error updating resource

│ with microsoft365_graph_beta_device_and_app_management_assignment_filter.example,
│ on microsoft365_graph_beta_device_and_app_management_assignment_filter.tf line 1, in resource "microsoft365_graph_beta_device_and_app_management_assignment_filter" "example":
│ 1: resource "microsoft365_graph_beta_device_and_app_management_assignment_filter" "example" {

│ Could not update with ID : No OData route exists that match template ~/singleton/navigation with http verb
│ PATCH for request
│ /GnT/StatelessPayloadLinkingService/8d87088f-ffff-3257-0602-071717505659/deviceManagement/assignmentFilters.

</details>


### Configuration

- OS: macOS

### Other information

_No response_
@ShocOne ShocOne added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 25, 2024
@rkodev rkodev self-assigned this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants