Send in http request body param as array - Invalid array - advanced-rest-client

I use extension Advanced Rest client
And I want to send POST request with 3 params in body.
On of them must be array.
I use this
but I get error:
{
"error": {
"message": "Invalid array",
"param": "payment_method_types",
"type": "invalid_request_error"
}
}

The value you entered is not valid application/www-url-encoded value. In the editor you have "Encode payload" button that transforms the value you entered to valid message. It should be something like:
success_url=https%3A%2F%2Fexample.com%2Fsuccess&cancel_url=https%3A%2F%2Fexample.com%2Fcancel&payment_method_types=%5B%22card%22%5D
You can see the exact sent message in the response details, under request headers, and the "source message".

Related

Assign the claimsMappingPolicy to a servicePrincipal giving error?

I have followed the below stackoverflow link ( The answer provided by Allen Wu)
How to add a custom claim and retrieve the same as part of access_token, when the scope is not Graph API in Azure AD?
to add a custom claim in access token. But I am getting an error when I am trying to
Assign the claimsMappingPolicy to a servicePrincipal.
I have opened microsoft graph and executed a POST call like so -
https://graph.microsoft.com/v1.0/servicePrincipals/8b6e2827-b3fa-467b-940d-324c301ca606/claimsMappingPolicies/$ref
with the request body
{
"#odata.id":"https://graph.microsoft.com/v1.0/policies/claimsMappingPolicies/fce7f260-9598-426d-b8c2-7e589b25415b"
}
but I am getting a 409 Response code with the following response preview :
{
"error": {
"code": "Request_MultipleObjectsWithSameKeyValue",
"message": "Request contains property changes that would result in property-uniqueness violation(s). Please retry your request with corrected values.",
"innerError": {
"date": "2020-10-18T06:32:23",
"request-id": "ae69cb4f-716d-4d56-a123-572c76ace2e0",
"client-request-id": "29b0130e-8b7a-d09d-1188-2856c99dad8e"
}
}
}
It means the servicePrincipal has been assigned a claimsMappingPolicy.
If you assign another claimsMappingPolicy to it, you will get the 409 Conflict error.
You need to List assigned claimsMappingPolicy first and then Remove claimsMappingPolicy.
Now you can assign claimsMappingPolicy to the servicePrincipal.

Agromonitoring POST Request for Polygon Creation

So I am trying to follow the documentation with the example for Create a polygon.
This request should return an ID that I should be able to GET as a geoTIFF/PNG or else afterwards.
I am using Postman to try my POST request - see the picture.
The response I get is:
"name": "UnprocessableEntityError",
"message": "Your polygon needs a name"
I followed the example and cannot seem to find the error - my body does define a name.
You need to change the Content-Type from text to JSON. Like this:

Counterparty sent session rejection message at unexpected time with message Unable to establish session

My question is that when I create the second state, Corda throws a exception. And here is exception: "message": "net.corda.core.flows.UnexpectedFlowEndException: Counterparty sent session rejection message at unexpected time with message Unable to establish session". But the first state can store in Corda's default database.
So it is weird.
first state:[
{
"foud_name": "23",
"financing_name":"23",
"financing_project":"23",
"company_name":"23",
"data_producer":"23",
"attachment_name":"23",
"attachment_type":"23",
"attachment_id":"23"
}
]
When I store the second , It throws an exception:
{
"timestamp": "2018-08-24T09:47:02.654+0000",
"status": 500,
"error": "Internal Server Error",
"message": "net.corda.core.flows.UnexpectedFlowEndException: Counterparty sent session rejection message at unexpected time with message Unable to establish session",
"path": "/api/v1/resarch-attachment"
}
This error message indicates that:
As part of a flow, you are sending a message to a counterparty
The counterparty has a response flow registered to respond to the flow that is sending the message, but it doesn't expect to receive a message at this time
There are several reasons this could happen. The response flow may already have ended, or it may not be expecting to receive a message at this time.
You say that the error message only happens the second time. With the details I have, I'd hypothesise that your initiating flow is trying to make the counterparty to invoke the response flow multiple times. Something like:
#InitiatingFlow
#StartableByRPC
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
val counterpartySession = initiateFlow(counterparty)
(0..99).forEach {
counterpartySession.send("My payload.")
}
}
}
#InitiatedBy(InitiatorFlow::class)
class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
counterpartySession.receive<String>()
}
}
This will not work. When you start an initiating flow, it is given a flow ID. This ID is used when communicating with counterparties to tell them which response flow to use:
If the counterparty has never received a message from a flow with this ID, it will create a new instance of the response flow
If the counterparty has received a message from a flow with this ID before, it will continue using this instance
If this flow instance has finished running, it will not create a new instance, but assume there has been a mistake, giving the error message you see above
Instead, you'd need to use subflows to create a new flow ID for each communication with the counterparty. Something like:
#InitiatingFlow
#StartableByRPC
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
(0..99).forEach {
subFlow(SendMessageFlow(counterparty))
}
}
}
#InitiatingFlow
class SendMessageFlow(val counterparty: Party) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
val counterpartySession = initiateFlow(counterparty)
counterpartySession.send("My payload.")
}
}
#InitiatedBy(SendMessageFlow::class)
class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
counterpartySession.receive<String>()
}
}

How to insert message with Content-Type message/rfc2822 using Gmail API?

I wanna write a small application that copy Gmail messages from one user folder to another. My approach is next:
Get raw message data to temporary placeholder;
Compose message using raw message data from the previous step;
Add message to required folder.
I can get raw message data as RFC 2822 formatted and base64url encoded string using this get request.
Also I can insert message to user mailbox with insert request. As documentation states, I can use one of the next two approaches:
use /upload URL (then I need an uploadType string and I should have a content-type of message/rfc822);
not using /upload URL and simply set message metadata in the request body -
something like the next JSON:
{
"labelIds": [
"INBOX",
"CATEGORY_PROMOTIONS"
],
"raw": "UmVjZWl2ZWQ6IGZyb20gMjkyODI0MTMyMDgyDQoJ..."
}
Unfortunately, when I don't use /upload URL (approach (2)) I can't insert message with attachment bigger than 5MB. But if I use /upload URL (approach (1)) I get response with error
"Media type 'message/rfc2822' is not supported. Valid media types: [message/rfc822]".
How can I support insertion of messages to Gmail without restriction on messages attachment size?

How to get correct $http error code, instead of -1?

I use $http to retrieve data from server. In case error happen, all statusCode = -1. I cannot get correct errorCode to handle in client. I don't have permission to update server code.
$http(options).then(function (response) {
if (response.status === 200) {
resolve(response.data);
} else {
exceptionHandler(response);
}
}, function (error) {
exceptionHandler(error);
});
console.log is put on exceptionHandler function.
Please help me get correct error code. Many thanks.
In the responses you have shown, the 404 error is available as error.status but the other two responses were denied access by your browser when it performed the preflight OPTIONS request.
In that case the browser returns a status of -1 to indicate that the request was aborted. There is no HTTP status code for your request because it was never sent. The status 500 shown in the console log is not made available to any javascript code.
You should handle a status of -1 as indicating that no response was received from the server, either because it was never sent (this case), or because it was sent but timed out.

Resources