-
Notifications
You must be signed in to change notification settings - Fork 15
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
Specifying content type in request to application/x-www-form-urlencoded fails #18
Comments
Thanks for flagging this! After checking out the issue, it seems like the problem lies in how the body is set up in the request mappings. In the provided Request resource, the body field within the mappings expects a jq filter. To fix this, just make sure to put the string in parentheses, like this: apiVersion: http.crossplane.io/v1alpha1
kind: Request
metadata:
name: example
spec:
deletionPolicy: Delete
forProvider:
mappings:
- headers:
Content-Type:
- application/x-www-form-urlencoded
method: POST
body: ("param1=val1¶m2=val2") # Enclose the string within parentheses
url: >-
(.payload.baseUrl + "/" +
"some/path/")
payload:
baseUrl: 'https://some-url'
managementPolicy: FullControl
providerConfigRef:
name: http-conf
That should sort out the unexpected token issue. Oh, and I noticed you didn't include a GET mapping. Without it, the provider might struggle to validate that the resource is up to date. If you're looking to perform a one-time request, consider using the DisposableRequest resource instead. Here's a quick example: apiVersion: http.crossplane.io/v1alpha1
kind: DesposibleRequest
metadata:
name: example
spec:
deletionPolicy: Orphan
forProvider:
url: https://some-url/some/path
method: POST
body: param1=val1¶m2=val2
headers:
Content-Type:
- application/x-www-form-urlencoded
providerConfigRef:
name: http-conf
No need to worry about jq here; just specify the body without parentheses and you're good to go! Hope this helps! Let me know if you have any further questions or concerns. |
Hello, thanks ill check it out, i m working on doing a missing configuration in keycloak (feat missing in upstream tf provider), my workflow is
If i understand it correctly, i would have to include get request as well making the overall flow to be
|
Thanks for sharing your workflow! It sounds like you’re on the right track. Considering your scenario, it seems you’ll need to perform three requests:
Just to clarify, DisposableRequest is typically used for one-time interactions, while Request is more suitable for managing resources through HTTP requests. Let me know if you have any questions or need further clarification on implementing these steps. |
@arielsepton thanks for the comprehensive reply, it helps. Ill go with a combination of desposible request + request for performing this configuration. |
I have a request that im making from cli against keycloak api using
creating this resource as replacement for above command but it fails
it might be something with the api but your insight would be helpful if any. |
Could you please share the status of the DisposableRequest resource? It contains the response from the server, which will help us troubleshoot the issue. |
Please find the error below :
Edit :
|
It seems the request was sent successfully, indicating a potential issue with the request payload. Before proceeding, could you please provide the entire status of the DisposableRequest resource? This will help us diagnose the problem more accurately. |
Please find the status of DesposableRequest resource below,
|
Thanks for providing the status.
The only differences I noticed are the Accept header and the password in the request body. These variances could be causing the issue. However, since the request was successfully sent, the problem likely doesn’t lie with the provider. If you have any other insights or need further assistance, feel free to let me know! |
hey @arielsepton, thanks alot for your support I tried sending the same request with kind: Request and its working, I'm guessing that kind: DisposableRequest somehow messes the request body before sending it. |
I’m glad to hear that it worked for you with the However, it’s unlikely that the request body is being altered differently between the two resources, especially since the same HTTP client class is used to perform the request in both cases. |
hmmm, might be possible I did had another question, Whats a better way to provide credentials to this resource ? currently im including creds in body, but i would want it to be read from a secret as variables which are then specified in the body The examples in this repo use injectedidentity that i dont really understand. |
Currently, you can achieve this by leveraging provider-kubernetes. You can refer to this example for guidance: link. While the feature of using secrets data directly is still in development, utilizing provider-kubernetes can fulfill this requirement in the interim. |
What happened?
Specifying content type in request to application/x-www-form-urlencoded and setting the body to param1=val1¶m2=val2 gives
How can we reproduce it?
Deploying a request resource with following spec
What environment did it happen in?
Crossplane version: 1.14.0
Distribution: Openshift
The text was updated successfully, but these errors were encountered: