RestTemplate considering a resource to be a parameter - rest

My request goes like this... https://......./results/#codeResults
When i hit this get request with postman, i get the desired output. (Please note that #codeResults is used as it is in the request and is not to be replaced by any value)
But when I try to hit this using exchange method of RestTemplate it says -
Status Code : 400
message: invalid resultId: #codeResults
As an alternative approach, I tried to pass #codeResults as a path param using URIComponentBuilder as well but still I am getting the same issue.
Please provide any pointers on this.

Related

Getting error "Action Error: Missing result from request body"

I'm running one of the examples in my own project and running into the error.
Action Error: Missing result from request body
Github Sample Project: dialogflow-silly-name-maker-webhook-nodejs
Hookbin: Shows the webhook coming from the assistant.https://hookbin.com/bin/ZjPzJ1Yb
Might there be an error in the sample code or in my set-up?
I was getting this error. In my case it was because the request object I was passing to ActionsSdkApp() constructor had a body property which was a JSON string as opposed to data structure.
Adding this in before instantiating ActionsSdkApp fixed it for me...
request.body = JSON.parse(request.body);
Then I could carry on like this...
App = new ActionsSdkApp({'request': request, 'response': response});
That error message is printed by the Action on Google client library if the incoming request doesn't have the intent information, but your JSON looks good.
Make sure your action enables debug logging for the client library: process.env.DEBUG = 'actions-on-google:*';
Then study the complete log to understand your issue.

Invalid_request_parameter (create and sending envelopes)

I'm trying to use a service of DocuSign API in an abap project. I want to send a document to a specific email so it can be signed. But im getting the following error:
"errorCode": "INVALID_REQUEST_PARAMETER",## "message": "The request contained at least one invalid parameter. Query parameter 'from_date' must be set to a valid DateTime, or 'envelope_ids' or 'transaction_ids' must be specified.
I tried the following:
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = l_url (https://demo.docusign.net/restapi/v2/accounts/XXXXXX')
proxy_host = co_proxy_host
proxy_service = co_proxy_service
IMPORTING
client = lo_http_client
lo_http_client->request->set_method( method = 'POST').
CALL METHOD lo_http_client->request->set_header_field
EXPORTING
name = 'Accept'
value = 'application/json'.
CALL METHOD lo_http_client->request->set_header_field
EXPORTING
name = 'X-DocuSign-Authentication'
value = get_auth_header( ). (json auth header)
CALL METHOD lo_http_client->request->set_cdata
EXPORTING
data = create_body( ).
This is my body:
CONCATENATE
`{`
`"emailSubject": "DocuSign REST API Quickstart Sample",`
`"emailBlurb": "Shows how to create and send an envelope from a document.",`
`"recipients": {`
`"signers": [{`
`"email": "test#email",`
`"name": "test",`
`"recipientId": "1",`
`"routingOrder": "1"`
`}]`
`},`
`"documents": [{`
`"documentId": "1",`
`"name": "test.pdf",`
`"documentBase64":` `"` l_encoded_doc `"`
`}],`
`"status": "sent"`
`}` INTO re_data.
The api request to get the Baseurl is working fine. (I know the error is quite specific what the problem is, but i cant find any sources on the docusign api documentation that one of the mentioned parameters should be added to the request)
Thank you in regards
The error message seems to indicate that you're Posting to an endpoint that requires certain query string parameters -- but you're not specifying them as expected in the query string. I'd suggest you check the DocuSign API documentation for the operation you are using, to determine what query string parameters it requires, and then ensure that you're including those parameters in your request URL.
If you can't figure this out using the documentation, then I'd suggest that you update your post to clarify exactly what URL (endpoint) you are using for the request, including any querystring parameters you're specifying in the URL. You can put fake values for things like Account ID, of course -- we just need to see the endpoint you are calling, and what qs params you're sending.
To create an envelope, use
https://demo.docusign.net/restapi/v2/accounts/XXXXXX/envelopes
instead of
https://demo.docusign.net/restapi/v2/accounts/XXXXXX
Thank you for all the answers, i found the mistake. Creating the request wasn´t the problem. I was using the wrong "sending"-method -_-.
now its working :)
lo_rest_client->post( EXPORTING io_entity = lo_request_entity ).

How can I get multiple %-encoded parameters into an apiary URI template?

The ApiaryIO spec—actually the RFC to which it points—indicates that you cannot use "." in a parameter name, you need to encode it to "%2E". That's fine, but there seems to be a bug where Apiary can only handle one such encoding. For example, the following
## Notes Collection [/notes{?foo%2Ebar}]
yields the following Code Example
request = Request('http://private-d1ee7-testingnewapiary.apiary-mock.com/notes?foo.bar=foo.bar')
which is correct. However, the following
## Notes Collection [/notes{?foo%2Ebar,baz%2Ebla}]
yields this Code Example:
request = Request('http://private-d1ee7-testingnewapiary.apiary-mock.com/notes?foo%252Ebar=foo%252Ebar&baz%252Ebla=baz%252Ebla')
Notice how in the first the Code Example you see it has "foo.bar" but in the second example it has "foo%252Ebar", which is incorrect.
The downstream effect here is that the incorrect URI is sent to the API server so the response is malformatted creating an error.
How do I encode many "."-containing parameters on the URI template and still get the proper code examples?
Will adding explicit example values for those parameters help?
For example:
## Notes Collection [/notes{?foo%2Ebar,baz%2Ebla}]
+ Parameters
+ foo%2Ebar (`42`)
+ baz%2Ebla (`24`)
Update
This seems to be a bug in the way the documentation / code samples are rendered. I have created the tracking issue here https://github.com/apiaryio/language-templates/issues/36.

403 forbidden error PUT request with yiirestfull plugin and Backbone.JS

I am working with REST in Yii. Therefore I use yiirestful plugin and Backbone.JS. At the moment I am perfectly able to do POST and GET request throughout REST. But when I want to update a record I alway get an 403 forbidden error. I shall explain what i've tried and how:
First of all I am saving my collection in Backbone like this:
Backbone.sync('update', this.collection);
Now I don't for sure if that's going to work but the fact is that any PUT request get's an 403.
Secondly, because I am working in a module I adjusted the URLmanager rules like this:
'contentManagement/api/<controller:\w+>'=>array('contentManagement/<controller>/restList', 'verb'=>'GET'),
'api/<controller:\w+>'=>array('<controller>/restList', 'verb'=>'GET'),
'api/<controller:\w+>/<id:\w+>'=>array('<controller>/restView', 'verb'=>'GET'),
'api/<controller:\w+>/<id:\w+>/<var:\w+>'=>array('<controller>/restView', 'verb'=>'GET'),
array('contentManagement/<controller>/restCreate', 'pattern'=>'contentManagement/api/<controller:\w+>', 'verb'=>'POST'),
array('<controller>/restUpdate', 'pattern'=>'contentManagement/api/<controller:\w+>/<id:\d+>', 'verb'=>'PUT'),
array('<controller>/restUpdate', 'pattern'=>'contentManagement/api/<controller:\w+>/<id:\d+>', 'verb'=>'PUT'),
array('<controller>/restDelete', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'DELETE'),
array('<controller>/restCreate', 'pattern'=>'contentManagement/api/<controller:\w+>', 'verb'=>'POST'),
array('<controller>/restCreate', 'pattern'=>'contentManagement/api/<controller:\w+>/<id:\w+>', 'verb'=>'POST'),
It could be the case that this causes the problem. But I am not very digged in to this rules.. I did the same as i did by the POST request but whatever I try it still gives the 403.
Thirdly i'll provide my request information:
PUT http://pimtest.php/Yii/trackstar/contentManagement/api/SidebarWidgetsUsed/
403 Forbidden
38ms
I think a id is needed after this url but when I provide an id in the data that should be enough to let backbone recognize it's about an PUT request / update request.
I have no clue where to look further in my code.. I understand it's a complicated story so any minimal advice is appreciated!
Greetz,
You have two (identical) rules that apply to PUT, and as you say, they require an ID. Without an ID, none of the rules will match for a PUT request.
Either provide an ID, or modify the rule to not require an id, e.g.:
array('<controller>/restUpdate', 'pattern'=>'contentManagement/api/<controller:\w+>', 'verb'=>'PUT'),
In any case, as you're not using id, I'm not sure why it's in the rule to start?

JSON endpoint with .NET RIA Domainservice

I have created a RIA-service and added a JSON endpoint following this tutorial: http://www.c-sharpcorner.com/UploadFile/pchandraker/1320/. When testing it in the browser, hitting
http://localhost:52878/Project-Web-DomainService.svc/json/GetProjects
returns nothing. When inspecting the request in Firebug, neither the response headers or body is set. Hitting an invalid url, such as http://localhost:52878/Project-Web-DomainService.svc/json/GetProjectsINVALID returns a 404, saying "Endpoint not found" as expected.
Do I need to add additional metadata or configuration settings to either DomainService.cs or Web.config to get the JSON output?
Decorate your GetProjects functions from DomainService with [QueryAttribute(HasSideEffects = true)] attribute.
Good luck.