how to retrieve the request body parameters in magento 2.0 [duplicate] - magento2

This question already exists:
How to get json data sent as post method after user requested the url API
Closed 6 years ago.
Client request url with some POST data. How can I retrieve that variable using CURL?
I have to retrieve that in JSON format variable and do the operation using those variables.

we insert our JSON DATA in REQUEST BODY in this form
{ "firstname":"vijay", "secondname":"bokka", "email":"vijayiiitn#gmail.com" }
as part of api implementation one method will be invoked when api url is trigged.
to that method interface write
apiinvokedmethod($firstname,$secondname,$email)
{
}
you can access value of '$firstname' automatically in the class where you implemented this interface class
NOTE:: The value of KEY in json and name of the METHOD PARAMETERE should be equal

Related

What POST method argument type should I declare to receive un-serialized data?

The user is sending me some JSON data to my REST API POST method - which could be 1 of 2 types of data.
I would like to receive whatever is sent over the network - may be as un-serialized string and I can determine which type it is by checking certain keyword.
My question is what type should I declare in my post method to receive this JSON data?
[HttpPost]
public void Post(WhatTypeShouldIDeclareHere type){}

Cannot pass value to SalesForce from Docusign Document, SOAP API, MergeFieldXml

Good day everyone,
I need to pass the value of a write-back field from docusign document to Salesforce.
Can you kindly provide an example of a string specifying the properties of MergeFieldXml like configuration type, path, etc.
According to Docusign SOAP API (https://www.docusign.net/api/3.0/dsapi.asmx?op=RequestEnvelopeWithDocumentFields) the MergeField property is passed as string:
<MergeFieldXml>string</MergeFieldXml>
At the same time the string should contain properties like:
Configuration type: salesforce (always)
path: objetc.field
row: record id
writeback: true if the data should be posted to salesforce.
My try does not work showing 'Web service callout failed: WebService returned a SOAP Fault: A Mergefield value for a Tab could not be retrieved. faultcode=soap:Client faultactor=missing in Web.Config
Row Number: 1196'
tab19.MergeFieldXml = '<configurationType>salesforce</configurationType><path>contact.Question_1_Agreement__c</path><writeback>true</writeback><allowSenderToEdit>false</allowSenderToEdit>';
If using REST API this would look as follows:
"mergeField": {
"configurationType":"Salesforce",
"path":"contact.Question_1_Agreement__c",
"writeback":"true",
"allowSenderToEdit":"true",
}
According to SOAP API documentation (https://www.docusign.com/p/APIGuide/APIGuide.htm#Sending Group/Tab.htm%3FTocPath%3DDocuSign%2520Service%2520API%2520Information%7CSending%2520Function%2520Group%7CCreateAndSendEnvelope%2520and%2520CreateEnvelope%7CTab%7C_____0)
MergeFieldXml is 'reserved for future'.
Does it mean it is not implemented yet?
how do we pass values back to salesforce using SOAP MergeFieldXml?
Or there may be some other way to accomplish this?
Thank you for any advise.

admin-on-rest Rest Client not mapping record with GET_ONE secondary API call

I have a GET_LIST that calls an API, displaying me an object of data. But when I create the Edit component which is under the same resource component, I am calling a second API call that shows additional data for that GET_ONE item.
My issue, is that although I can configure a GET_ONE call inside my rest client, I am unable to get the Edit component do use the GET_ONE API call response object. It is still using the GET_ALL API call response object.
Here's some sample code. Note, that my GET_ONE api call doesn't have {resource} because the URL link doesn't have that word.
const API_URL = 'https://api.link/biglist';
const 2API_URL2 = 'https://api.link/address=123456';
switch (type) {
case GET_LIST: {
url = `${API_URL}/${resource}`;
break;
}
case
GET_ONE:
url = `${2API_URL2}/${params.id}`;
break;
Inside the Edit component, I have an ImageField. By console logging the record inside the ImageField component, I can see that the record response object is using the GET_ALL API response, instead of GET_ONE API response.
I have made sure that when I access the Edit component of a specific item inside the GET_LIST, my Edit component does indeed make an API call to my secondary API request, and it does return me the response object of the secondary request. I just can't somehow map the secondary API response with record inside ImageField.
So my question is, how do I get the GET_ONE response inside my Edit component (which is under the same resource component) to use my second API response and map it with record?
I solved my problem by adding a fetch API call inside my resource components, and created custom field components to use my secondary API calls instead of using record. I feel there's a much better solution, but this'll do.

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 ).

Using save or put with Restangular results in "undefined" being included in URL

I am using Restangular to download an object, update it and then attempt to save back to the server using the save method. Here is the code that retrieves the object:
Restangular.one("survey", surveyID).getList().then (
function (response) {
$scope.survey = response[0];
}
);
This sets $scope.survey to a properly "restangularized" object, with the fields that come back from the GET request, along with the methods like save, put, etc.
If I then invoke the following function after making some edits to the $scope.survey object:
$scope.saveChanges = function () {
$scope.survey.save();
};
restangular tries to use the URL /survey/1/undefined for the PUT request (1 is the correct ID for the object).
My survey object doesn't have an id field (it's surveyID instead), and so I suspected this might be the problem. However, replacing the surveyID field with an id field changed the URL to be /survey/1/undefined/1
I have stripped down the object returned by the GET request to be just primitives, and this does not change the situation.
Why is the incorrect route being generated?
II discovered the problem was actually with the REST service; when called with GET /surveys/1, it was returning an array with a single object in it, rather than returning the object itself.
I think this caused restangular to think that a collection was being accessed (note that I was having to call getList rather than get in order to get a properly restangularized object).